forked from kubernetes-retired/multi-tenancy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a unit test for config_controller.go
Add a unit test for config_controller.go to test the case that when a new type is added to HNCConfiguration singleton, the corresponding object reconciler can be created correctly. This PR also moves shared helper functions from each controller test files to a common file. Design doc: http://bit.ly/hnc-type-configuration Issue: kubernetes-retired#411
- Loading branch information
1 parent
483fdfa
commit 3bee2dd
Showing
7 changed files
with
352 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package controllers_test | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("HNCConfiguration", func() { | ||
ctx := context.Background() | ||
|
||
var ( | ||
fooName string | ||
barName string | ||
) | ||
|
||
BeforeEach(func() { | ||
fooName = createNS(ctx, "foo") | ||
barName = createNS(ctx, "bar") | ||
}) | ||
|
||
AfterEach(func() { | ||
// Change current singleton back to the default value. | ||
Eventually(func() error { | ||
c := getHNCConfig(ctx) | ||
return resetHNCConfigToDefault(ctx, c) | ||
}).Should(Succeed()) | ||
}) | ||
|
||
It("should propagate objects whose types have been added to HNCConfiguration", func() { | ||
setParent(ctx, barName, fooName) | ||
makeSecret(ctx, fooName, "foo-sec") | ||
|
||
// Wait 1 second to give "foo-sec" a chance to be propagated to bar, if it can be propagated. | ||
time.Sleep(1 * time.Second) | ||
// Foo should have "foo-sec" since we created it there. | ||
Eventually(hasSecret(ctx, fooName, "foo-sec")).Should(BeTrue()) | ||
// "foo-sec" is not propagated to bar because Secret hasn't been configured in HNCConfiguration. | ||
Eventually(hasSecret(ctx, barName, "foo-sec")).Should(BeFalse()) | ||
|
||
Eventually(func() error { | ||
c := getHNCConfig(ctx) | ||
return addSecretToHNCConfig(ctx, c) | ||
}).Should(Succeed()) | ||
|
||
// "foo-sec" should now be propagated from foo to bar. | ||
Eventually(hasSecret(ctx, barName, "foo-sec")).Should(BeTrue()) | ||
Expect(secretInheritedFrom(ctx, barName, "foo-sec")).Should(Equal(fooName)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.