mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-03 11:45:45 +00:00
Pull controller-go back into this repository as internal/controllerlib.
Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
29
internal/controllerlib/testing.go
Normal file
29
internal/controllerlib/testing.go
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2020 VMware, Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package controllerlib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSync(t *testing.T, controller Controller, ctx Context) error {
|
||||
t.Helper() // force testing import to discourage external use
|
||||
return controller.sync(ctx)
|
||||
}
|
||||
|
||||
func TestWrap(t *testing.T, controller Controller, wrapper SyncWrapperFunc) {
|
||||
t.Helper() // force testing import to discourage external use
|
||||
controller.wrap(wrapper)
|
||||
}
|
||||
|
||||
// Just enough of the internal implementation of controller.Run() to allow
|
||||
// "running" the controller without any goroutines being involved. For use
|
||||
// in synchronous unit tests that wish to invoke TestSync() directly.
|
||||
func TestRunSynchronously(t *testing.T, controller Controller) {
|
||||
t.Helper() // force testing import to discourage external use
|
||||
controller.invokeAllRunOpts()
|
||||
controller.waitForCacheSyncWithTimeout()
|
||||
}
|
||||
Reference in New Issue
Block a user