@@ -20,76 +20,81 @@ import (
2020 "sort"
2121 "testing"
2222
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.
2424 . "github.com/onsi/gomega"
2525)
2626
2727func TestStage (t * testing.T ) {
28- RegisterFailHandler (g . Fail )
29- g . RunSpecs (t , "Stage Suite" )
28+ RegisterFailHandler (Fail )
29+ RunSpecs (t , "Stage Suite" )
3030}
3131
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" ,
3434 func (str string , stage Stage ) {
3535 s , err := ParseStage (str )
3636 Expect (err ).NotTo (HaveOccurred ())
3737 Expect (s ).To (Equal (stage ))
3838 },
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 ),
4242 )
4343
44- g . DescribeTable ("should error when parsing invalid stage strings" ,
44+ DescribeTable ("should error when parsing invalid stage strings" ,
4545 func (str string ) {
4646 _ , err := ParseStage (str )
4747 Expect (err ).To (HaveOccurred ())
4848 },
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" ),
5252 )
5353})
5454
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" ,
5858 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 , "" ),
6262 )
6363
64- g . DescribeTable ("should panic" ,
64+ DescribeTable ("should panic" ,
6565 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 )),
7070 )
7171 })
7272
73- g . Context ("Validate" , func () {
74- g . DescribeTable ("should validate existing stages" ,
73+ Context ("Validate" , func () {
74+ DescribeTable ("should validate existing stages" ,
7575 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 ),
7979 )
8080
81- g . DescribeTable ("should fail for non-existing stages" ,
81+ DescribeTable ("should fail for non-existing stages" ,
8282 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 )),
8787 )
8888 })
8989
90- g . Context ("Compare" , func () {
90+ Context ("Compare" , func () {
9191 // Test Stage.Compare by sorting a list
9292 var (
93+ stages []Stage
94+ sortedStages []Stage
95+ )
96+
97+ BeforeEach (func () {
9398 stages = []Stage {
9499 Stable ,
95100 Alpha ,
@@ -107,25 +112,25 @@ var _ = g.Describe("Stage", func() {
107112 Stable ,
108113 Stable ,
109114 }
110- )
115+ } )
111116
112- g . It ("sorts stages correctly" , func () {
117+ It ("sorts stages correctly" , func () {
113118 sort .Slice (stages , func (i int , j int ) bool {
114119 return stages [i ].Compare (stages [j ]) == - 1
115120 })
116121 Expect (stages ).To (Equal (sortedStages ))
117122 })
118123 })
119124
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 () {
122127 Expect (Stable .IsStable ()).To (BeTrue ())
123128 })
124129
125- g . DescribeTable ("should return false for any unstable stage" ,
130+ DescribeTable ("should return false for any unstable stage" ,
126131 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 ),
129134 )
130135 })
131136})
0 commit comments