This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 454
/
vcs_test.go
94 lines (90 loc) · 2.52 KB
/
vcs_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import "testing"
func TestGitDetermineDefaultBranch(t *testing.T) {
cases := []struct {
r, o string
v string
err bool
}{
{"test",
`* remote origin
Fetch URL: https://gopkg.in/mgo.v2
Push URL: https://gopkg.in/mgo.v2
HEAD branch: v2
Remote branches:
master tracked
v2 tracked
v2-unstable tracked
Local branches configured for 'git pull':
master merges with remote master
v2 merges with remote v2
Local refs configured for 'git push':
master pushes to master (up to date)
v2 pushes to v2 (local out of date)
`, "v2", false},
{"test",
`* remote origin
Fetch URL: https://gopkg.in/bluesuncorp/validator.v5
Push URL: https://gopkg.in/bluesuncorp/validator.v5
HEAD branch (remote HEAD is ambiguous, may be one of the following):
master
v5
Remote branches:
krhubert tracked
master tracked
v4 tracked
v5 tracked
v5-development tracked
v6 tracked
v6-development tracked
v7 tracked
v7-development tracked
v8 tracked
v8-development tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
`, "master", false},
{"test",
`* remote origin
Fetch URL: https://github.com/gin-gonic/gin
Push URL: https://github.com/gin-gonic/gin
HEAD branch: develop
Remote branches:
benchmarks tracked
better-bind-errors tracked
develop tracked
fasthttp tracked
fix-binding tracked
fix-tests tracked
gh-pages tracked
honteng-bind_test tracked
master tracked
new-binding-validator tracked
new-catch-all tracked
performance tracked
routes-list tracked
Local branch configured for 'git pull':
develop merges with remote develop
Local ref configured for 'git push':
develop pushes to develop (local out of date)
`, "develop", false},
{"test", "", "", true},
}
for i, test := range cases {
v, e := gitDetermineDefaultBranch(test.r, test.o)
if v != test.v {
t.Errorf("%d Unexpected value returned: %s, wanted %s", i, v, test.v)
}
if e != nil {
t.Log("Err", e.Error())
}
if test.err && e == nil {
t.Errorf("%d Test should err, but didn't", i)
}
if !test.err && e != nil {
t.Errorf("%d Test shouldn't err, but did with: %s", i, e)
}
}
}