aboutsummaryrefslogtreecommitdiffsponsor
path: root/internal/service/git_test.go
blob: 6dc8f62fd3ffe30265ab051d355d2f8f787fa3ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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")
}