-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull_test.go
50 lines (38 loc) · 1.43 KB
/
pull_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
43
44
45
46
47
48
49
50
package git_test
import (
"testing"
git "github.com/purpleclay/gitz"
"github.com/purpleclay/gitz/gittest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPull(t *testing.T) {
log := "(tag: 0.1.0, main, origin/main) feat: a new exciting feature"
gittest.InitRepository(t, gittest.WithRemoteLog(log))
require.NotEqual(t, gittest.LastCommit(t).Message, "feat: a new exciting feature")
client, _ := git.NewClient()
_, err := client.Pull()
require.NoError(t, err)
assert.Equal(t, gittest.LastCommit(t).Message, "feat: a new exciting feature")
tags := gittest.Tags(t)
assert.ElementsMatch(t, []string{"0.1.0"}, tags)
}
func TestPullWithFetchIgnoreTags(t *testing.T) {
log := `(tag: 0.3.0, main, origin/main) feat: third feature
(tag: 0.2.0) feat: second feature
(tag: 0.1.0) feat: first feature`
gittest.InitRepository(t, gittest.WithRemoteLog(log))
client, _ := git.NewClient()
_, err := client.Pull(git.WithFetchIgnoreTags())
require.NoError(t, err)
assert.Empty(t, gittest.Tags(t))
}
func TestPullWithPullRefSpecs(t *testing.T) {
log := `(main, origin/main) test: add test for validating refspecs
(origin/branch) fix: ensure pull supports refspecs`
gittest.InitRepository(t, gittest.WithLog(log))
client, _ := git.NewClient()
_, err := client.Pull(git.WithPullRefSpecs("branch:branch1"))
require.NoError(t, err)
assert.ElementsMatch(t, []string{"main", "branch1"}, gittest.Branches(t))
}