@@ -25,14 +25,14 @@ SOFTWARE.
2525package v3
2626
2727import (
28- "fmt"
28+ "errors"
29+ "os"
30+
2931 . "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo bdd
3032 . "github.com/onsi/gomega" //nolint:revive // ginkgo bdd
31- "os"
3233 "sigs.k8s.io/yaml"
3334
3435 pdoknlv3 "github.com/pdok/atom-operator/api/v3"
35- // TODO (user): Add any additional imports if needed
3636)
3737
3838var _ = Describe ("Atom Webhook" , func () {
@@ -79,11 +79,11 @@ var _ = Describe("Atom Webhook", func() {
7979 atom := & pdoknlv3.Atom {}
8080 err = yaml .Unmarshal (input , atom )
8181 Expect (err ).NotTo (HaveOccurred ())
82- warnings , errors := validator .ValidateCreate (ctx , atom )
82+ warnings , errorsCreate := validator .ValidateCreate (ctx , atom )
8383
84- expectedError := fmt . Errorf ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: metadata.labels: Required value: can't be empty" )
84+ expectedError := errors . New ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: metadata.labels: Required value: can't be empty" )
8585 Expect (len (warnings )).To (Equal (0 ))
86- Expect (expectedError .Error ()).To (Equal (errors .Error ()))
86+ Expect (expectedError .Error ()).To (Equal (errorsCreate .Error ()))
8787 })
8888
8989 It ("Should create and update atom without errors or warnings" , func () {
@@ -115,21 +115,21 @@ var _ = Describe("Atom Webhook", func() {
115115 atomOld := & pdoknlv3.Atom {}
116116 err = yaml .Unmarshal (input , atomOld )
117117 Expect (err ).NotTo (HaveOccurred ())
118- warnings , errors := validator .ValidateCreate (ctx , atomOld )
119- Expect (errors ).To (BeNil ())
120- Expect (len (warnings )).To (Equal (0 ))
118+ warningsCreate , errorsCreate := validator .ValidateCreate (ctx , atomOld )
119+ Expect (errorsCreate ).To (BeNil ())
120+ Expect (len (warningsCreate )).To (Equal (0 ))
121121
122122 By ("simulating an invalid update scenario. error label names cannot be added or deleted" )
123123 input , err = os .ReadFile ("test_data/input/4-update-error-add-or-delete-labels.yaml" )
124124 Expect (err ).NotTo (HaveOccurred ())
125125 atomNew := & pdoknlv3.Atom {}
126126 err = yaml .Unmarshal (input , atomNew )
127127 Expect (err ).NotTo (HaveOccurred ())
128- warnings , errors = validator .ValidateUpdate (ctx , atomOld , atomNew )
128+ warningsUpdate , errorsUpdate : = validator .ValidateUpdate (ctx , atomOld , atomNew )
129129
130- expectedError := fmt . Errorf ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: [metadata.labels.pdok.nl/dataset-id: Required value: labels cannot be removed, metadata.labels.pdok.nl/dataset-idsssssssss: Forbidden: new labels cannot be added]" )
131- Expect (len (warnings )).To (Equal (0 ))
132- Expect (expectedError .Error ()).To (Equal (errors .Error ()))
130+ expectedError := errors . New ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: [metadata.labels.pdok.nl/dataset-id: Required value: labels cannot be removed, metadata.labels.pdok.nl/dataset-idsssssssss: Forbidden: new labels cannot be added]" )
131+ Expect (len (warningsUpdate )).To (Equal (0 ))
132+ Expect (expectedError .Error ()).To (Equal (errorsUpdate .Error ()))
133133 })
134134
135135 It ("Should deny update atom with error label names are immutable" , func () {
@@ -139,21 +139,21 @@ var _ = Describe("Atom Webhook", func() {
139139 atomOld := & pdoknlv3.Atom {}
140140 err = yaml .Unmarshal (input , atomOld )
141141 Expect (err ).NotTo (HaveOccurred ())
142- warnings , errors := validator .ValidateCreate (ctx , atomOld )
143- Expect (errors ).To (BeNil ())
144- Expect (len (warnings )).To (Equal (0 ))
142+ warningsCreate , errorsCreate := validator .ValidateCreate (ctx , atomOld )
143+ Expect (errorsCreate ).To (BeNil ())
144+ Expect (len (warningsCreate )).To (Equal (0 ))
145145
146146 By ("simulating an invalid update scenario. Lablels are immutable" )
147147 input , err = os .ReadFile ("test_data/input/5-update-error-labels-immutable.yaml" )
148148 Expect (err ).NotTo (HaveOccurred ())
149149 atomNew := & pdoknlv3.Atom {}
150150 err = yaml .Unmarshal (input , atomNew )
151151 Expect (err ).NotTo (HaveOccurred ())
152- warnings , errors = validator .ValidateUpdate (ctx , atomOld , atomNew )
152+ warningsUpdate , errorsUpdate : = validator .ValidateUpdate (ctx , atomOld , atomNew )
153153
154- expectedError := fmt . Errorf ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: metadata.labels.pdok.nl/dataset-id: Invalid value: \" wetlands-changed\" : immutable: should be wetlands" )
155- Expect (len (warnings )).To (Equal (0 ))
156- Expect (expectedError .Error ()).To (Equal (errors .Error ()))
154+ expectedError := errors . New ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: metadata.labels.pdok.nl/dataset-id: Invalid value: \" wetlands-changed\" : immutable: should be wetlands" )
155+ Expect (len (warningsUpdate )).To (Equal (0 ))
156+ Expect (expectedError .Error ()).To (Equal (errorsUpdate .Error ()))
157157 })
158158
159159 It ("Should deny update atom with error URL are immutable" , func () {
@@ -163,8 +163,8 @@ var _ = Describe("Atom Webhook", func() {
163163 atomOld := & pdoknlv3.Atom {}
164164 err = yaml .Unmarshal (input , atomOld )
165165 Expect (err ).NotTo (HaveOccurred ())
166- warnings , errors := validator .ValidateCreate (ctx , atomOld )
167- Expect (errors ).To (BeNil ())
166+ warnings , errorsCreate := validator .ValidateCreate (ctx , atomOld )
167+ Expect (errorsCreate ).To (BeNil ())
168168 Expect (len (warnings )).To (Equal (0 ))
169169
170170 By ("simulating an invalid update scenario. URL is immutable" )
@@ -173,11 +173,11 @@ var _ = Describe("Atom Webhook", func() {
173173 atomNew := & pdoknlv3.Atom {}
174174 err = yaml .Unmarshal (input , atomNew )
175175 Expect (err ).NotTo (HaveOccurred ())
176- warnings , errors = validator .ValidateUpdate (ctx , atomOld , atomNew )
176+ warnings , errorsUpdate : = validator .ValidateUpdate (ctx , atomOld , atomNew )
177177
178- expectedError := fmt . Errorf ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: spec.service.baseUrl: Forbidden: is immutable" )
178+ expectedError := errors . New ("Atom.pdok.nl \" asis-readonly-prod\" is invalid: spec.service.baseUrl: Forbidden: is immutable" )
179179 Expect (len (warnings )).To (Equal (0 ))
180- Expect (expectedError .Error ()).To (Equal (errors .Error ()))
180+ Expect (expectedError .Error ()).To (Equal (errorsUpdate .Error ()))
181181 })
182182 })
183183})
0 commit comments