test

package
v0.0.0-...-741fd3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 65

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONEquals

func JSONEquals(t Failer, a, b string)

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

func NewContext(t Failer) context.Context

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

func SetAtomicBoolForTest(t Failer, vv *atomic.Bool, v bool)

SetAtomicBoolForTest sets a variable for the duration of a test, then resets it once the test is complete atomically.

func SetEnvForTest

func SetEnvForTest(t Failer, k, v string)

SetEnvForTest sets an environment variable for the duration of a test, then resets it once the test is complete.

func SetForTest

func SetForTest[T any](t Failer, vv *T, v T)

SetForTest sets a variable for the duration of a test, then resets it once the test is complete.

func Wrap

func Wrap(f func(t Failer)) error

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.

type Fuzzer

type Fuzzer interface {
	Fuzz(ff any)
	Add(args ...any)
}

Fuzzer abstracts *testing.F

Directories

Path Synopsis
ca
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
yml

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL