-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_test.go
42 lines (33 loc) · 979 Bytes
/
git_test.go
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
35
36
37
38
39
40
41
42
package dpull
import (
"context"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestGit(t *testing.T) {
option := DefaultRepoOption
os.RemoveAll(option.StorePath)
git, err := NewGitClient(option, GitClientOption{})
require.Nil(t, err)
err = git.Clone(context.Background())
require.Nil(t, err)
err = git.Pull(context.Background())
require.NotNil(t, err)
require.Contains(t, err.Error(), "already up-to-date")
_, err = os.Stat(option.StorePath)
require.Nil(t, err)
_, err = os.Stat(filepath.Join(option.StorePath, ".git"))
require.Nil(t, err)
data := "FROM ubuntu"
dockerfile := filepath.Join(option.StorePath, "Dockerfile")
err = ioutil.WriteFile(dockerfile, []byte(data), 0755)
require.Nil(t, err)
err = git.AddAndCommit([]string{dockerfile}, "change docker file")
require.Nil(t, err)
// tags:release-v$version
_, err = git.TagAndPush("release-vgit-test3", "change docker file")
require.Nil(t, err)
}