mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-21 02:56:26 +10:00
Fix up bugs in unit testing framework
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user