Generalize SetupFakeContext to be able to serve tests and benchmarks. (#1134)

This commit is contained in:
Markus Thömmes 2020-03-03 17:33:53 +01:00 committed by GitHub
parent 73701f1aa5
commit 52cba6da6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -18,7 +18,8 @@ package testing
import (
"context"
"testing"
"go.uber.org/zap/zaptest"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
@ -29,14 +30,14 @@ import (
)
// SetupFakeContext sets up the the Context and the fake informers for the tests.
func SetupFakeContext(t *testing.T) (context.Context, []controller.Informer) {
func SetupFakeContext(t zaptest.TestingT) (context.Context, []controller.Informer) {
c, _, is := SetupFakeContextWithCancel(t)
return c, is
}
// SetupFakeContextWithCancel sets up the the Context and the fake informers for the tests
// The provided context can be canceled using provided callback.
func SetupFakeContextWithCancel(t *testing.T) (context.Context, context.CancelFunc, []controller.Informer) {
func SetupFakeContextWithCancel(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) {
ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t))
ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000))
ctx, is := injection.Fake.SetupInformers(ctx, &rest.Config{})