@@ -20,76 +20,81 @@ import (
20
20
"sort"
21
21
"testing"
22
22
23
- g "github.com/onsi/ginkgo/v2" // An alias is required because Context is defined elsewhere in this package.
23
+ . "github.com/onsi/ginkgo/v2" // An alias is required because Context is defined elsewhere in this package.
24
24
. "github.com/onsi/gomega"
25
25
)
26
26
27
27
func TestStage (t * testing.T ) {
28
- RegisterFailHandler (g . Fail )
29
- g . RunSpecs (t , "Stage Suite" )
28
+ RegisterFailHandler (Fail )
29
+ RunSpecs (t , "Stage Suite" )
30
30
}
31
31
32
- var _ = g . Describe ("ParseStage" , func () {
33
- g . DescribeTable ("should be correctly parsed for valid stage strings" ,
32
+ var _ = Describe ("ParseStage" , func () {
33
+ DescribeTable ("should be correctly parsed for valid stage strings" ,
34
34
func (str string , stage Stage ) {
35
35
s , err := ParseStage (str )
36
36
Expect (err ).NotTo (HaveOccurred ())
37
37
Expect (s ).To (Equal (stage ))
38
38
},
39
- g . Entry ("for alpha stage" , "alpha" , Alpha ),
40
- g . Entry ("for beta stage" , "beta" , Beta ),
41
- g . Entry ("for stable stage" , "" , Stable ),
39
+ Entry ("for alpha stage" , "alpha" , Alpha ),
40
+ Entry ("for beta stage" , "beta" , Beta ),
41
+ Entry ("for stable stage" , "" , Stable ),
42
42
)
43
43
44
- g . DescribeTable ("should error when parsing invalid stage strings" ,
44
+ DescribeTable ("should error when parsing invalid stage strings" ,
45
45
func (str string ) {
46
46
_ , err := ParseStage (str )
47
47
Expect (err ).To (HaveOccurred ())
48
48
},
49
- g . Entry ("passing a number as the stage string" , "1" ),
50
- g . Entry ("passing `gamma` as the stage string" , "gamma" ),
51
- g . Entry ("passing a dash-prefixed stage string" , "-alpha" ),
49
+ Entry ("passing a number as the stage string" , "1" ),
50
+ Entry ("passing `gamma` as the stage string" , "gamma" ),
51
+ Entry ("passing a dash-prefixed stage string" , "-alpha" ),
52
52
)
53
53
})
54
54
55
- var _ = g . Describe ("Stage" , func () {
56
- g . Context ("String" , func () {
57
- g . DescribeTable ("should return the correct string value" ,
55
+ var _ = Describe ("Stage" , func () {
56
+ Context ("String" , func () {
57
+ DescribeTable ("should return the correct string value" ,
58
58
func (stage Stage , str string ) { Expect (stage .String ()).To (Equal (str )) },
59
- g . Entry ("for alpha stage" , Alpha , "alpha" ),
60
- g . Entry ("for beta stage" , Beta , "beta" ),
61
- g . Entry ("for stable stage" , Stable , "" ),
59
+ Entry ("for alpha stage" , Alpha , "alpha" ),
60
+ Entry ("for beta stage" , Beta , "beta" ),
61
+ Entry ("for stable stage" , Stable , "" ),
62
62
)
63
63
64
- g . DescribeTable ("should panic" ,
64
+ DescribeTable ("should panic" ,
65
65
func (stage Stage ) { Expect (func () { _ = stage .String () }).To (Panic ()) },
66
- g . Entry ("for stage 34" , Stage (34 )),
67
- g . Entry ("for stage 75" , Stage (75 )),
68
- g . Entry ("for stage 123" , Stage (123 )),
69
- g . Entry ("for stage 255" , Stage (255 )),
66
+ Entry ("for stage 34" , Stage (34 )),
67
+ Entry ("for stage 75" , Stage (75 )),
68
+ Entry ("for stage 123" , Stage (123 )),
69
+ Entry ("for stage 255" , Stage (255 )),
70
70
)
71
71
})
72
72
73
- g . Context ("Validate" , func () {
74
- g . DescribeTable ("should validate existing stages" ,
73
+ Context ("Validate" , func () {
74
+ DescribeTable ("should validate existing stages" ,
75
75
func (stage Stage ) { Expect (stage .Validate ()).To (Succeed ()) },
76
- g . Entry ("for alpha stage" , Alpha ),
77
- g . Entry ("for beta stage" , Beta ),
78
- g . Entry ("for stable stage" , Stable ),
76
+ Entry ("for alpha stage" , Alpha ),
77
+ Entry ("for beta stage" , Beta ),
78
+ Entry ("for stable stage" , Stable ),
79
79
)
80
80
81
- g . DescribeTable ("should fail for non-existing stages" ,
81
+ DescribeTable ("should fail for non-existing stages" ,
82
82
func (stage Stage ) { Expect (stage .Validate ()).NotTo (Succeed ()) },
83
- g . Entry ("for stage 34" , Stage (34 )),
84
- g . Entry ("for stage 75" , Stage (75 )),
85
- g . Entry ("for stage 123" , Stage (123 )),
86
- g . Entry ("for stage 255" , Stage (255 )),
83
+ Entry ("for stage 34" , Stage (34 )),
84
+ Entry ("for stage 75" , Stage (75 )),
85
+ Entry ("for stage 123" , Stage (123 )),
86
+ Entry ("for stage 255" , Stage (255 )),
87
87
)
88
88
})
89
89
90
- g . Context ("Compare" , func () {
90
+ Context ("Compare" , func () {
91
91
// Test Stage.Compare by sorting a list
92
92
var (
93
+ stages []Stage
94
+ sortedStages []Stage
95
+ )
96
+
97
+ BeforeEach (func () {
93
98
stages = []Stage {
94
99
Stable ,
95
100
Alpha ,
@@ -107,25 +112,25 @@ var _ = g.Describe("Stage", func() {
107
112
Stable ,
108
113
Stable ,
109
114
}
110
- )
115
+ } )
111
116
112
- g . It ("sorts stages correctly" , func () {
117
+ It ("sorts stages correctly" , func () {
113
118
sort .Slice (stages , func (i int , j int ) bool {
114
119
return stages [i ].Compare (stages [j ]) == - 1
115
120
})
116
121
Expect (stages ).To (Equal (sortedStages ))
117
122
})
118
123
})
119
124
120
- g . Context ("IsStable" , func () {
121
- g . It ("should return true for stable stage" , func () {
125
+ Context ("IsStable" , func () {
126
+ It ("should return true for stable stage" , func () {
122
127
Expect (Stable .IsStable ()).To (BeTrue ())
123
128
})
124
129
125
- g . DescribeTable ("should return false for any unstable stage" ,
130
+ DescribeTable ("should return false for any unstable stage" ,
126
131
func (stage Stage ) { Expect (stage .IsStable ()).To (BeFalse ()) },
127
- g . Entry ("for alpha stage" , Alpha ),
128
- g . Entry ("for beta stage" , Beta ),
132
+ Entry ("for alpha stage" , Alpha ),
133
+ Entry ("for beta stage" , Beta ),
129
134
)
130
135
})
131
136
})
0 commit comments