@@ -62,7 +62,7 @@ var _ = Describe("Atom Webhook", func() {
6262 Context ("When creating or updating Atom under Validating Webhook" , func () {
6363 It ("Should create atom without errors or warnings" , func () {
6464 By ("simulating a valid creation scenario" )
65- input , err := os .ReadFile ("test_data/input/1-no-error-no-warning.yaml" )
65+ input , err := os .ReadFile ("test_data/input/1-create- no-error-no-warning.yaml" )
6666 Expect (err ).NotTo (HaveOccurred ())
6767 atom := & pdoknlv3.Atom {}
6868 err = yaml .Unmarshal (input , atom )
@@ -73,7 +73,7 @@ var _ = Describe("Atom Webhook", func() {
7373 })
7474 It ("Should deny creation if no labels are available" , func () {
7575 By ("simulating an invalid creation scenario" )
76- input , err := os .ReadFile ("test_data/input/2-error-no-lables.yaml" )
76+ input , err := os .ReadFile ("test_data/input/2-create- error-no-lables.yaml" )
7777 Expect (err ).NotTo (HaveOccurred ())
7878 atom := & pdoknlv3.Atom {}
7979 err = yaml .Unmarshal (input , atom )
@@ -84,6 +84,28 @@ var _ = Describe("Atom Webhook", func() {
8484 Expect (len (warnings )).To (Equal (0 ))
8585 Expect (expectedError .Error ()).To (Equal (errors .Error ()))
8686 })
87+
88+ It ("Should create and update atom without errors or warnings" , func () {
89+ By ("simulating a valid creation scenario" )
90+ input , err := os .ReadFile ("test_data/input/1-create-no-error-no-warning.yaml" )
91+ Expect (err ).NotTo (HaveOccurred ())
92+ atomOld := & pdoknlv3.Atom {}
93+ err = yaml .Unmarshal (input , atomOld )
94+ Expect (err ).NotTo (HaveOccurred ())
95+ warnings , errors := validator .ValidateCreate (ctx , atomOld )
96+ Expect (errors ).To (BeNil ())
97+ Expect (len (warnings )).To (Equal (0 ))
98+
99+ By ("simulating a valid update scenario" )
100+ input , err = os .ReadFile ("test_data/input/3-update-no-error-no-warning.yaml" )
101+ Expect (err ).NotTo (HaveOccurred ())
102+ atomNew := & pdoknlv3.Atom {}
103+ err = yaml .Unmarshal (input , atomNew )
104+ Expect (err ).NotTo (HaveOccurred ())
105+ warnings , errors = validator .ValidateUpdate (ctx , atomOld , atomNew )
106+ Expect (errors ).To (BeNil ())
107+ Expect (len (warnings )).To (Equal (0 ))
108+ })
87109 })
88110
89111})
0 commit comments