forked from x-motemen/ghq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_test.go
86 lines (70 loc) · 1.58 KB
/
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
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
package main
import (
. "github.com/onsi/gomega"
"testing"
)
func TestGitConfigAll(t *testing.T) {
RegisterTestingT(t)
Expect(GitConfigAll("ghq.non.existent.key")).To(HaveLen(0))
}
func TestGitConfigURL(t *testing.T) {
RegisterTestingT(t)
if GitHasFeatureConfigURLMatch() == false {
t.Skip("Git does not have config --get-urlmatch feature")
}
reset, err := WithGitconfigFile(`
[ghq "https://ghe.example.com/"]
vcs = github
[ghq "https://ghe.example.com/hg/"]
vcs = hg
`)
if err != nil {
t.Fatal(err)
}
defer reset()
var (
value string
)
value, err = GitConfig("--get-urlmatch", "ghq.vcs", "https://ghe.example.com/foo/bar")
Expect(err).NotTo(HaveOccurred())
Expect(value).To(Equal("github"))
value, err = GitConfig("--get-urlmatch", "ghq.vcs", "https://ghe.example.com/hg/repo")
Expect(err).NotTo(HaveOccurred())
Expect(value).To(Equal("hg"))
value, err = GitConfig("--get-urlmatch", "ghq.vcs", "https://example.com")
Expect(err).NotTo(HaveOccurred())
Expect(value).To(Equal(""))
}
func TestGitVersionOutputSatisfies(t *testing.T) {
RegisterTestingT(t)
Expect(
gitVersionOutputSatisfies(
"git version 1.7.9",
[]uint{1, 8, 5},
),
).To(BeFalse())
Expect(
gitVersionOutputSatisfies(
"git version 1.8.2.3",
[]uint{1, 8, 5},
),
).To(BeFalse())
Expect(
gitVersionOutputSatisfies(
"git version 1.8.5",
[]uint{1, 8, 5},
),
).To(BeTrue())
Expect(
gitVersionOutputSatisfies(
"git version 1.9.1",
[]uint{1, 8, 5},
),
).To(BeTrue())
Expect(
gitVersionOutputSatisfies(
"git version 2.0.0",
[]uint{1, 8, 5},
),
).To(BeTrue())
}