Skip to content

Commit

Permalink
Merge pull request #365 from ksimon1/handle-update-CR-err
Browse files Browse the repository at this point in the history
Fix tests ID 5990 and ID 5989
  • Loading branch information
kubevirt-bot committed May 31, 2022
2 parents f30d14a + 3c35e0b commit 1ea41aa
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package tests

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -149,8 +152,6 @@ var _ = Describe("Validation webhook", func() {

BeforeEach(func() {
strategy.SkipSspUpdateTestsIfNeeded()

foundSsp = getSsp()
})

AfterEach(func() {
Expand All @@ -159,15 +160,20 @@ var _ = Describe("Validation webhook", func() {

Context("Placement API validation", func() {
It("[test_id:5990]should succeed with valid template-validator placement fields", func() {
foundSsp.Spec.TemplateValidator.Placement = &placementAPIValidationValidPlacement
Expect(apiClient.Update(ctx, foundSsp, client.DryRunAll)).ToNot(HaveOccurred(),
"failed to update SSP CR with valid template-validator placement fields")
Eventually(func() error {
foundSsp = getSsp()
foundSsp.Spec.TemplateValidator.Placement = &placementAPIValidationValidPlacement
return apiClient.Update(ctx, foundSsp, client.DryRunAll)
}, time.Second, tenSecondTimeout).ShouldNot(HaveOccurred(), "failed to update SSP CR with valid template-validator placement fields")
})

It("[test_id:5989]should fail with invalid template-validator placement fields", func() {
foundSsp.Spec.TemplateValidator.Placement = &placementAPIValidationInvalidPlacement
Expect(apiClient.Update(ctx, foundSsp, client.DryRunAll)).To(HaveOccurred(),
"SSP CR updated with invalid template-validator placement fields")
Eventually(func() v1.StatusReason {
foundSsp = getSsp()
foundSsp.Spec.TemplateValidator.Placement = &placementAPIValidationInvalidPlacement
err := apiClient.Update(ctx, foundSsp, client.DryRunAll)
return errors.ReasonForError(err)
}, time.Second, tenSecondTimeout).Should(Equal(metav1.StatusReasonInvalid), "SSP CR updated with invalid template-validator placement fields")
})
})
})
Expand Down

0 comments on commit 1ea41aa

Please sign in to comment.