Refactor tests into function
@@ -37,14 +37,11 @@ import (
var _ = Describe("Core API Validation", func() {
testBaseName := "core-api-validation"
f := framework.NewKubeFedFramework(testBaseName)
- var namespace string
BeforeEach(func() {
if framework.TestContext.InMemoryControllers {
framework.Skipf("Running validation admission webhook outside of cluster not supported")
}
-
- namespace = f.TestNamespaceName()
})
resourcesToValidate := []string{ftc.ResourceName, kfcluster.ResourceName}
@@ -52,9 +49,15 @@ var _ = Describe("Core API Validation", func() {
resourceName := resourcesToValidate[i]
vrt := newValidationResourceTest(resourceName)
vrt.initialize()
+ runValidationResourceTests(f, vrt, resourceName, testBaseName)
+ }
+})
+
+func runValidationResourceTests(f framework.KubeFedFramework, vrt validationResourceTest, resourceName, testBaseName string) {
It(fmt.Sprintf("for %s should fail when an invalid %s is created or updated", resourceName, resourceName), func() {
userAgent := fmt.Sprintf("test-%s-validation", resourceName)
client := f.Client(userAgent)
+ namespace := f.TestNamespaceName()
vrt.getObjectMeta().Namespace = namespace
By(fmt.Sprintf("Creating an invalid %s", resourceName))
@@ -113,7 +116,6 @@ var _ = Describe("Core API Validation", func() {
})
})
}
-})
type validationResourceTest interface {
initialize() pkgruntime.Object
