fixed a flaky unit test case.
@@ -41,6 +41,7 @@ var _ = Describe("PolicyChecker", func() {
JustBeforeEach(func() {
policyCheck, err := policy.Initialize(testLogger, "some-cluster", "some-version", policyFilter)
Expect(err).ToNot(HaveOccurred())
+ Expect(policyCheck).ToNot(BeNil())
pass, checkErr = policychecker.NewApiPolicyChecker(policyCheck).Check("some-action", fakeAccess, fakeRequest)
})
@@ -74,7 +75,6 @@ var _ = Describe("PolicyChecker", func() {
Expect(fakePolicyAgent.CheckCallCount()).To(Equal(0))
})
})
- })
Context("when the http method no need to check", func() {
BeforeEach(func() {
@@ -92,6 +92,8 @@ var _ = Describe("PolicyChecker", func() {
Context("when not in action list", func() {
BeforeEach(func() {
+ fakeRequest = httptest.NewRequest("PUT", "/something", nil)
+ policyFilter.HttpMethods = []string{}
policyFilter.Actions = []string{}
})
It("should pass", func() {
@@ -214,3 +216,4 @@ var _ = Describe("PolicyChecker", func() {
})
})
})
+})
