-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhotfix_test.go
90 lines (77 loc) · 2.53 KB
/
hotfix_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
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("Hotfix", func() {
var branches []Branch
BeforeEach(func() {
f1, _ := NewHotfix("0.0.1")
f2, _ := HotfixFromBranch(BRANCH_NAME_PREFIX + "hotfix/v0.0.1")
f3, _ := BranchFromBranchName(BRANCH_NAME_PREFIX + "hotfix/v0.0.1")
f4, _ := BranchFromBranchName("hotfix/v0.0.1")
branches = []Branch{f1, f2, f3, f4}
})
It("is of type hotfix branch", func() {
f, _ := NewHotfix("a")
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.(Branch).CanBeClosed()).To(Equal(true))
})
})
It("closes on release branches & develop branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
closeBanches := branch.(Branch).CloseBranches(MockBranchCollection())
Expect(len(closeBanches)).To(Equal(2))
Expect(closeBanches[0].ShortBranchName()).To(Equal(RELEASE_BRANCH))
Expect(closeBanches[1].ShortBranchName()).To(Equal(DEVELOP_BRANCH))
})
})
It("is only allowed to create from master branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
f := branch.(Branch)
for _, testBranch := range MockBranchCollection() {
testBranchName := testBranch.ShortBranchName()
if testBranchName == MASTER_BRANCH {
Expect(f.CreationIsAllowedFrom(testBranch)).To(BeTrue())
} else {
Expect(f.CreationIsAllowedFrom(testBranch)).To(BeFalse())
}
}
})
})
It("can be published", func() {
ForEachTestSet(branches, func(branch interface{}) {
Expect(branch.(Branch).CanBePublished()).To(BeTrue())
})
})
It("can be published on master", func() {
ForEachTestSet(branches, func(branch interface{}) {
publishBranch := branch.(Branch).PublishBranch()
Expect(publishBranch.ShortBranchName()).To(Equal(MASTER_BRANCH))
})
})
// settings like default branch
// ----------------------------
It("has a branch name", func() {
ForEachTestSet(branches, func(branch interface{}) {
branchName := branch.(Branch).BranchName()
Expect(branchName).To(Equal(BRANCH_NAME_PREFIX + HOTFIX_BRANCH))
})
})
It("has a short branch name", func() {
ForEachTestSet(branches, func(branch interface{}) {
branchName := branch.(Branch).ShortBranchName()
Expect(branchName).To(Equal(HOTFIX_BRANCH))
})
})
})