diff options
Diffstat (limited to 'internal/service/git_test.go')
-rw-r--r-- | internal/service/git_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/service/git_test.go b/internal/service/git_test.go new file mode 100644 index 0000000..6dc8f62 --- /dev/null +++ b/internal/service/git_test.go @@ -0,0 +1,34 @@ +package service + +import ( + "os/exec" + "path" + "strings" + "testing" + + "git.server.ky/slackcoder/mirror/internal" + "github.com/stretchr/testify/require" +) + +func requireTagExist(t *testing.T, filePath string, tag string, msgAndArgs ...interface{}) { + cmd := exec.Command("git", "tag") + cmd.Dir = filePath + + buf, err := cmd.Output() + require.NoError(t, err) + + tags := strings.Fields(string(buf)) + require.Contains(t, tags, tag, msgAndArgs...) +} + +func TestMirrorGit(t *testing.T) { + d := t.TempDir() + + dst := internal.MustURL(path.Join(d, "merchant")) + src := internal.MustURL("https://git.taler.net/merchant.git") + + err := MirrorGit(dst, src, "GNU Taler Merchant") + require.NoError(t, err, "git mirror") + + requireTagExist(t, dst.Path, "v0.11.3", "tag must exist") +} |