6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-11 12:59:15 +00:00

Refactor Clone method to use go-git

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-27 12:54:49 +02:00
parent 616b476ce1
commit b94e655d4a
5 changed files with 99 additions and 19 deletions

View File

@@ -1,6 +1,44 @@
package new
import "testing"
import (
"testing"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-billy/v5/memfs"
)
func TestRepoCloneInMemory(t *testing.T) {
path := memfs.New()
repo, err := CloneRepo("https://github.com/grdl/dotfiles", path)
checkFatal(t, err)
wt, err := repo.repo.Worktree()
checkFatal(t, err)
files, err := wt.Filesystem.ReadDir("")
checkFatal(t, err)
if len(files) == 0 {
t.Errorf("Cloned repo should contain files")
}
}
func TestRepoCloneOnDisk(t *testing.T) {
path := osfs.New(newTempDir(t))
repo, err := CloneRepo("https://github.com/grdl/dotfiles", path)
checkFatal(t, err)
wt, err := repo.repo.Worktree()
checkFatal(t, err)
files, err := wt.Filesystem.ReadDir("")
checkFatal(t, err)
if len(files) == 0 {
t.Errorf("Cloned repo should contain files")
}
}
func TestRepoEmpty(t *testing.T) {
repo := newTestRepo(t)