Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests ID 5990 and ID 5989 #365

Merged
merged 1 commit into from
May 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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