Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Avinash Patnala <[email protected]>
  • Loading branch information
Avinash Patnala committed Oct 23, 2024
1 parent eeee348 commit 80c7275
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"reflect"
"time"

"github.com/go-logr/logr"
"github.com/open-policy-agent/frameworks/constraint/pkg/apis/templates/v1beta1"
constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client"
"github.com/open-policy-agent/frameworks/constraint/pkg/core/templates"
Expand Down Expand Up @@ -70,12 +69,13 @@ var (
discoveryErr *apiutil.ErrResourceDiscoveryFailed
)

var g *logr.Logger
var gvkConstraintTemplate = schema.GroupVersionKind{
Group: v1beta1.SchemeGroupVersion.Group,
Version: v1beta1.SchemeGroupVersion.Version,
Kind: "ConstraintTemplate",
}
var (
gvkConstraintTemplate = schema.GroupVersionKind{
Group: v1beta1.SchemeGroupVersion.Group,
Version: v1beta1.SchemeGroupVersion.Version,
Kind: "ConstraintTemplate",
}
)

type Adder struct {
CFClient *constraintclient.Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/open-policy-agent/gatekeeper/v3/pkg/controller/constraint"
"github.com/open-policy-agent/gatekeeper/v3/pkg/drivers/k8scel"
celSchema "github.com/open-policy-agent/gatekeeper/v3/pkg/drivers/k8scel/schema"
"github.com/open-policy-agent/gatekeeper/v3/pkg/drivers/k8scel/transform"
"github.com/open-policy-agent/gatekeeper/v3/pkg/fakes"
"github.com/open-policy-agent/gatekeeper/v3/pkg/readiness"
"github.com/open-policy-agent/gatekeeper/v3/pkg/target"
Expand Down Expand Up @@ -271,8 +272,8 @@ func TestReconcile(t *testing.T) {
ctx := context.Background()
testutils.StartManager(ctx, t, mgr)

constraint.VapAPIEnabled = ptr.To[bool](true)
constraint.GroupVersion = &admissionregistrationv1beta1.SchemeGroupVersion
transform.VapAPIEnabled = ptr.To[bool](true)
transform.GroupVersion = &admissionregistrationv1beta1.SchemeGroupVersion

t.Run("CRD Gets Created", func(t *testing.T) {
suffix := "CRDGetsCreated"
Expand Down Expand Up @@ -696,7 +697,7 @@ func TestReconcile(t *testing.T) {
suffix := "VapShouldBeCreatedV1"

logger.Info("Running test: Vap should be created with v1")
constraint.GroupVersion = &admissionregistrationv1.SchemeGroupVersion
transform.GroupVersion = &admissionregistrationv1.SchemeGroupVersion
constraintTemplate := makeReconcileConstraintTemplateForVap(suffix, ptr.To[bool](true))
t.Cleanup(testutils.DeleteObjectAndConfirm(ctx, t, c, expectedCRD(suffix)))
testutils.CreateThenCleanup(ctx, t, c, constraintTemplate)
Expand All @@ -721,7 +722,7 @@ func TestReconcile(t *testing.T) {
suffix := "VapBindingShouldBeCreatedV1"
logger.Info("Running test: VapBinding should be created with v1")
constraint.DefaultGenerateVAPB = ptr.To[bool](true)
constraint.GroupVersion = &admissionregistrationv1.SchemeGroupVersion
transform.GroupVersion = &admissionregistrationv1.SchemeGroupVersion
constraintTemplate := makeReconcileConstraintTemplateForVap(suffix, ptr.To[bool](true))
cstr := newDenyAllCstr(suffix)
t.Cleanup(testutils.DeleteObjectAndConfirm(ctx, t, c, expectedCRD(suffix)))
Expand Down

0 comments on commit 80c7275

Please sign in to comment.