-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrelease_test.go
89 lines (76 loc) · 2.44 KB
/
release_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("Release", func() {
var branches []Branch
BeforeEach(func() {
f1, _ := NewRelease("1.2.3")
f2, _ := ReleaseFromBranch(BRANCH_NAME_PREFIX + "release/v1.2.3")
f3, _ := BranchFromBranchName(BRANCH_NAME_PREFIX + "release/v1.2.3")
f4, _ := BranchFromBranchName("release/v1.2.3")
branches = []Branch{f1, f2, f3, f4}
})
It("is of type release branch", func() {
f, _ := NewRelease("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("can be published", func() {
ForEachTestSet(branches, func(branch interface{}) {
Expect(branch.(Branch).CanBePublished()).To(Equal(true))
})
})
It("only closes on release branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
closeBanches := branch.(Branch).CloseBranches(MockBranchCollection())
Expect(len(closeBanches)).To(Equal(1))
Expect(closeBanches[0].ShortBranchName()).To(Equal(DEVELOP_BRANCH))
})
})
It("is only allowed to create from develop branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
f := branch.(Branch)
for _, testBranch := range MockBranchCollection() {
testBranchName := testBranch.ShortBranchName()
if testBranchName == DEVELOP_BRANCH {
Expect(f.CreationIsAllowedFrom(testBranch)).To(BeTrue())
} else {
Expect(f.CreationIsAllowedFrom(testBranch)).To(BeFalse())
}
}
})
})
It("publishes on the master branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
f := branch.(Branch)
Expect(f.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 + RELEASE_BRANCH))
})
})
It("has a short branch name", func() {
ForEachTestSet(branches, func(branch interface{}) {
branchName := branch.(Branch).ShortBranchName()
Expect(branchName).To(Equal(RELEASE_BRANCH))
})
})
})