@@ -22,7 +22,7 @@ var _ = Describe("BIOSVersion Webhook", func() {
2222
2323 BeforeEach (func () {
2424 validator = BIOSVersionCustomValidator {Client : k8sClient }
25- By ("Creating an BIOSVersion" )
25+ By ("Creating a BIOSVersion" )
2626 biosVersionV1 = & metalv1alpha1.BIOSVersion {
2727 ObjectMeta : metav1.ObjectMeta {
2828 GenerateName : "test-" ,
@@ -40,14 +40,14 @@ var _ = Describe("BIOSVersion Webhook", func() {
4040 })
4141
4242 AfterEach (func () {
43- By ("Deleting the BIOSVersion and Server resources" )
43+ By ("Deleting the BIOSVersion resources" )
4444 Expect (k8sClient .DeleteAllOf (ctx , & metalv1alpha1.BIOSVersion {})).To (Succeed ())
4545
4646 By ("Ensuring clean state" )
4747 controller .EnsureCleanState ()
4848 })
4949
50- It ("Should deny creation if a spec.serverRef field is duplicate" , func (ctx SpecContext ) {
50+ It ("Should deny creation if spec.serverRef is duplicate" , func (ctx SpecContext ) {
5151 By ("Creating another BIOSVersion with existing ServerRef" )
5252 biosVersionV2 := & metalv1alpha1.BIOSVersion {
5353 ObjectMeta : metav1.ObjectMeta {
@@ -80,11 +80,11 @@ var _ = Describe("BIOSVersion Webhook", func() {
8080 ServerRef : & v1.LocalObjectReference {Name : "bar" },
8181 },
8282 }
83- Expect (k8sClient . Create (ctx , biosVersionV2 )).To ( Succeed ())
83+ Expect (validator . ValidateCreate (ctx , biosVersionV2 )).Error (). ToNot ( HaveOccurred ())
8484 })
8585
86- It ("Should deny update if a spec.serverRef field is a duplicate" , func () {
87- By ("Creating an BIOSVersion with different ServerRef" )
86+ It ("Should deny update if spec.serverRef is duplicate" , func () {
87+ By ("Creating a BIOSVersion with different ServerRef" )
8888 biosVersionV2 := & metalv1alpha1.BIOSVersion {
8989 ObjectMeta : metav1.ObjectMeta {
9090 GenerateName : "test-" ,
@@ -100,14 +100,14 @@ var _ = Describe("BIOSVersion Webhook", func() {
100100 }
101101 Expect (k8sClient .Create (ctx , biosVersionV2 )).To (Succeed ())
102102
103- By ("Updating an BIOSVersion V2 to conflicting spec.serverRef" )
103+ By ("Updating a BIOSVersion V2 to conflicting spec.serverRef" )
104104 biosVersionV2Updated := biosVersionV2 .DeepCopy ()
105105 biosVersionV2Updated .Spec .ServerRef = & v1.LocalObjectReference {Name : "foo" }
106106 Expect (validator .ValidateUpdate (ctx , biosVersionV2 , biosVersionV2Updated )).Error ().To (HaveOccurred ())
107107 })
108108
109109 It ("Should allow update if a different field is duplicate" , func () {
110- By ("Creating an BIOSVersion with different ServerRef" )
110+ By ("Creating a BIOSVersion with different ServerRef" )
111111 biosVersionV2 := & metalv1alpha1.BIOSVersion {
112112 ObjectMeta : metav1.ObjectMeta {
113113 GenerateName : "test-" ,
@@ -123,14 +123,14 @@ var _ = Describe("BIOSVersion Webhook", func() {
123123 }
124124 Expect (k8sClient .Create (ctx , biosVersionV2 )).To (Succeed ())
125125
126- By ("Updating an BIOSVersion V2 to conflicting spec.biosVersionSpec " )
126+ By ("Updating BIOSVersion V2 to duplicate spec.image " )
127127 biosVersionV2Updated := biosVersionV2 .DeepCopy ()
128128 biosVersionV2Updated .Spec .Image = biosVersionV1 .Spec .Image
129129 Expect (validator .ValidateUpdate (ctx , biosVersionV2 , biosVersionV2Updated )).Error ().ToNot (HaveOccurred ())
130130 })
131131
132132 It ("Should allow update if a ServerRef field is not a duplicate" , func () {
133- By ("Creating an BIOSVersion with different ServerRef" )
133+ By ("Creating a BIOSVersion with different ServerRef" )
134134 biosVersionV2 := & metalv1alpha1.BIOSVersion {
135135 ObjectMeta : metav1.ObjectMeta {
136136 GenerateName : "test-" ,
@@ -146,19 +146,19 @@ var _ = Describe("BIOSVersion Webhook", func() {
146146 }
147147 Expect (k8sClient .Create (ctx , biosVersionV2 )).To (Succeed ())
148148
149- By ("Updating an BIOSVersion V2 to a non-conflicting spec.serverRef " )
149+ By ("Updating a BIOSVersion V2 to a non-conflicting spec.serverRef" )
150150 biosVersionV2Updated := biosVersionV2 .DeepCopy ()
151151 biosVersionV2Updated .Spec .ServerRef = & v1.LocalObjectReference {Name : "foobar" }
152152 Expect (validator .ValidateUpdate (ctx , biosVersionV2 , biosVersionV2Updated )).Error ().ToNot (HaveOccurred ())
153153 })
154154
155- It ("Should no allow update a BIOSVersion is in progress, but should allow to force update it " , func () {
155+ It ("Should not allow update when BIOSVersion is in progress, but should allow force update" , func () {
156156 By ("Patching the BIOSVersion V1 to in-progress state" )
157157 Eventually (UpdateStatus (biosVersionV1 , func () {
158158 biosVersionV1 .Status .State = metalv1alpha1 .BIOSVersionStateInProgress
159159 })).Should (Succeed ())
160160
161- By ("Add ServerMaintenance reference" )
161+ By ("Adding ServerMaintenance reference" )
162162 Eventually (Update (biosVersionV1 , func () {
163163 biosVersionV1 .Spec .ServerMaintenanceRef = & metalv1alpha1.ObjectReference {Name : "maintenance" }
164164 })).Should (Succeed ())
@@ -168,7 +168,7 @@ var _ = Describe("BIOSVersion Webhook", func() {
168168 biosVersionV1Updated .Spec .Version = "P712"
169169 Expect (validator .ValidateUpdate (ctx , biosVersionV1 , biosVersionV1Updated )).Error ().To (HaveOccurred ())
170170
171- By ("Updating an biosVersion V1 spec, should pass to update when inProgress with ForceUpdateResource finalizer " )
171+ By ("Updating BIOSVersion V1 spec should succeed when InProgress with ForceUpdateInProgress annotation " )
172172 biosVersionV1Updated .Annotations = map [string ]string {metalv1alpha1 .OperationAnnotation : metalv1alpha1 .OperationAnnotationForceUpdateInProgress }
173173 Expect (validator .ValidateUpdate (ctx , biosVersionV1 , biosVersionV1Updated )).Error ().ToNot (HaveOccurred ())
174174
@@ -179,17 +179,16 @@ var _ = Describe("BIOSVersion Webhook", func() {
179179 })
180180
181181 It ("Should refuse to delete if InProgress" , func () {
182- By ("Patching the BIOSVersionV1 to InProgress state" )
182+ By ("Patching the BIOSVersion V1 to InProgress state" )
183183 Eventually (UpdateStatus (biosVersionV1 , func () {
184184 biosVersionV1 .Status .State = metalv1alpha1 .BIOSVersionStateInProgress
185185 })).Should (Succeed ())
186186
187- By ("Deleting the BIOSSettings V1 should fail" )
188- Expect (k8sClient . Delete (ctx , biosVersionV1 )).To (Not ( Succeed () ))
187+ By ("Validating deletion of BIOSVersion V1 should fail" )
188+ Expect (validator . ValidateDelete (ctx , biosVersionV1 )).Error (). To (HaveOccurred ( ))
189189
190190 Eventually (UpdateStatus (biosVersionV1 , func () {
191191 biosVersionV1 .Status .State = metalv1alpha1 .BIOSVersionStateCompleted
192192 })).Should (Succeed ())
193193 })
194-
195194})
0 commit comments