-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfix_test.go
89 lines (76 loc) · 2.49 KB
/
fix_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
package glow_test
import (
"reflect"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/meinto/glow"
. "github.com/meinto/glow/testutil"
)
var _ = Describe("Fix", func() {
var branches []AuthoredBranch
BeforeEach(func() {
f1, _ := NewFix("luke", "falcon")
f2, _ := FixFromBranch(BRANCH_NAME_PREFIX + "fix/luke/falcon")
f3, _ := BranchFromBranchName(BRANCH_NAME_PREFIX + "fix/luke/falcon")
f4, _ := BranchFromBranchName("fix/luke/falcon")
branches = []AuthoredBranch{f1, f2, f3, f4}
})
It("is of type fix branch", func() {
f, _ := NewFix("a", "b")
rf := reflect.ValueOf(f)
ForEachTestSet(branches, func(branch interface{}) {
r := reflect.ValueOf(branch)
Expect(r.Type().AssignableTo(rf.Type())).To(BeTrue())
})
})
It("can be closed", func() {
ForEachTestSet(branches, func(branch interface{}) {
Expect(branch.(AuthoredBranch).CanBeClosed()).To(Equal(true))
})
})
It("only closes on release branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
closeBanches := branch.(AuthoredBranch).CloseBranches(MockBranchCollection())
Expect(len(closeBanches)).To(Equal(1))
Expect(closeBanches[0].ShortBranchName()).To(Equal(RELEASE_BRANCH))
})
})
It("is only allowed to create from release branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
f := branch.(AuthoredBranch)
for _, testBranch := range MockBranchCollection() {
testBranchName := testBranch.ShortBranchName()
if testBranchName == RELEASE_BRANCH {
Expect(f.CreationIsAllowedFrom(testBranch)).To(BeTrue())
} else {
Expect(f.CreationIsAllowedFrom(testBranch)).To(BeFalse())
}
}
})
})
// settings like default branch
// ----------------------------
It("cannot be published", func() {
ForEachTestSet(branches, func(branch interface{}) {
Expect(branch.(AuthoredBranch).CanBePublished()).To(BeFalse())
})
})
It("has no publish branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
publishBranch := branch.(AuthoredBranch).PublishBranch()
Expect(publishBranch).To(BeNil())
})
})
It("has a branch name", func() {
ForEachTestSet(branches, func(branch interface{}) {
branchName := branch.(AuthoredBranch).BranchName()
Expect(branchName).To(Equal(BRANCH_NAME_PREFIX + FIX_BRANCH))
})
})
It("has a short branch name", func() {
ForEachTestSet(branches, func(branch interface{}) {
branchName := branch.(AuthoredBranch).ShortBranchName()
Expect(branchName).To(Equal(FIX_BRANCH))
})
})
})