-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfeature_test.go
90 lines (77 loc) · 2.65 KB
/
feature_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("Feature", func() {
var branches []AuthoredBranch
BeforeEach(func() {
f1, _ := NewFeature("luke", "falcon-shuttle")
f2, _ := FeatureFromBranch("feature/luke/falcon-shuttle")
f3, _ := FeatureFromBranch(BRANCH_NAME_PREFIX + "feature/luke/falcon-shuttle")
f4, _ := BranchFromBranchName(BRANCH_NAME_PREFIX + "feature/luke/falcon-shuttle")
f5, _ := BranchFromBranchName("feature/luke/falcon-shuttle")
branches = []AuthoredBranch{f1, f2, f3, f4, f5}
})
It("is of type feature branch", func() {
f, _ := NewFeature("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 develop", func() {
ForEachTestSet(branches, func(branch interface{}) {
closeBanches := branch.(AuthoredBranch).CloseBranches([]Branch{})
Expect(len(closeBanches)).To(Equal(1))
Expect(closeBanches[0].ShortBranchName()).To(Equal(DEVELOP_BRANCH))
})
})
It("is allowed to create from develop or feature branch", func() {
ForEachTestSet(branches, func(branch interface{}) {
f := branch.(AuthoredBranch)
for _, testBranch := range MockBranchCollection() {
testBranchName := testBranch.ShortBranchName()
if testBranchName == DEVELOP_BRANCH || testBranchName == FEAUTURE_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 + FEAUTURE_BRANCH))
})
})
It("has a short branch name", func() {
ForEachTestSet(branches, func(branch interface{}) {
branchName := branch.(AuthoredBranch).ShortBranchName()
Expect(branchName).To(Equal(FEAUTURE_BRANCH))
})
})
})