Fix up bugs in unit testing framework

This commit is contained in:
James Munnelly
2018-04-04 23:40:44 +01:00
parent b866b8cdf4
commit 178a3a5eea
2 changed files with 19 additions and 4 deletions
+9 -3
View File
@@ -1,6 +1,7 @@
package acme
import (
"context"
"testing"
"k8s.io/apimachinery/pkg/runtime"
@@ -25,9 +26,11 @@ type acmeFixture struct {
Client *client.FakeACME
PreFn func(*acmeFixture)
CheckFn func(*acmeFixture)
CheckFn func(*acmeFixture, ...interface{})
Err bool
Ctx context.Context
// f is the integration test fixture being used for this test
f *unit.Fixture
}
@@ -36,6 +39,9 @@ func (s *acmeFixture) Setup(t *testing.T) {
if s.Client == nil {
s.Client = &client.FakeACME{}
}
if s.Ctx == nil {
s.Ctx = context.Background()
}
s.f = &unit.Fixture{
T: t,
KubeObjects: s.KubeObjects,
@@ -50,13 +56,13 @@ func (s *acmeFixture) Setup(t *testing.T) {
}
}
func (s *acmeFixture) Finish(t *testing.T) {
func (s *acmeFixture) Finish(t *testing.T, args ...interface{}) {
defer s.f.Stop()
// resync listers before running checks
s.f.Sync()
// run custom checks
if s.CheckFn != nil {
s.CheckFn(s)
s.CheckFn(s, args...)
}
}