Documentation ¶
Index ¶
- func JSONEquals(t Failer, a, b string)
- func NewContext(t Failer) context.Context
- func NewStop(t Failer) chan struct{}
- func SetAtomicBoolForTest(t Failer, vv *atomic.Bool, v bool)
- func SetEnvForTest(t Failer, k, v string)
- func SetForTest[T any](t Failer, vv *T, v T)
- func Wrap(f func(t Failer)) error
- type Failer
- type Fuzzer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONEquals ¶
JSONEquals compares two json strings. We cannot compare JSON strings from protobuf because of design decisions https://github.com/golang/protobuf/issues/1373 Instead, use this function to normalize the formatting
func NewContext ¶
NewContext returns a context that will automatically be closed when the test is complete
func NewStop ¶
func NewStop(t Failer) chan struct{}
NewStop returns a stop channel that will automatically be closed when the test is complete
func SetAtomicBoolForTest ¶
SetAtomicBoolForTest sets a variable for the duration of a test, then resets it once the test is complete atomically.
func SetEnvForTest ¶
SetEnvForTest sets an environment variable for the duration of a test, then resets it once the test is complete.
func SetForTest ¶
SetForTest sets a variable for the duration of a test, then resets it once the test is complete.
func Wrap ¶
Wrap executes a function with a fake Failer, and returns an error if the test failed. This allows calling functions that take a Failer and using them with functions that expect an error, or allowing calling functions that would cause a test to immediately fail to instead return an error. Wrap handles Cleanup() and short-circuiting of Fatal() just like the real testing.T.
Types ¶
type Failer ¶
type Failer interface { Fail() FailNow() Fatal(args ...any) Fatalf(format string, args ...any) Log(args ...any) Logf(format string, args ...any) TempDir() string Helper() Cleanup(func()) Skip(args ...any) }
Failer is an interface to be provided to test functions of the form XXXOrFail. This is a substitute for testing.TB, which cannot be implemented outside of the testing package.
Directories ¶
Path | Synopsis |
---|---|
csrctrl
|
|
controllers
An example implementation of a CSR Controller.
|
An example implementation of a CSR Controller. |
signer
Package signer implements a CA signer that uses keys stored on local disk.
|
Package signer implements a CA signer that uses keys stored on local disk. |
datasets
|
|
fakes
|
|
components/gcemetadata
Package gcemetadata provides basic utilities around configuring the fake GCE Metadata Server component for integration testing.
|
Package gcemetadata provides basic utilities around configuring the fake GCE Metadata Server component for integration testing. |
components/registryredirector
Package registryredirector provides basic utilities around configuring the fake image registry server component for integration testing.
|
Package registryredirector provides basic utilities around configuring the fake image registry server component for integration testing. |
loadbalancersim
|
|
util
|
|