Documentation
¶
Index ¶
- Constants
- Variables
- func ArtifactDir(t TestingTInterface) string
- func CleanRVAndTypeMeta(r runtime.Object)
- func CompareWithFixture(t *testing.T, output interface{}, opts ...Option)
- func Diff(t *testing.T, name string, x, y interface{}, opts ...cmp.Option)
- func GetFreePort(t TestingTInterface) string
- func ReadFromFixture(t *testing.T, identifier string) []byte
- func TmpDir(t *testing.T, files map[string]fstest.MapFile) (string, error)
- func Vault(t *testing.T) string
- func WaitForHTTP200(addr, command string, waitFor int64, t TestingTInterface)
- func WriteToFixture(t *testing.T, identifier string, data []byte)
- type Accessory
- type Option
- type Options
- type PortFlags
- type ReadyOption
- type ReadyOptions
- type T
- type TestingTInterface
Constants ¶
const VaultTestingRootToken = "jpuxZFWWFW7vM882GGX2aWOE"
Variables ¶
var ( // EquateErrorMessage reports errors to be equal if both are nil // or both have the same message. EquateErrorMessage = cmp.FilterValues(func(x, y interface{}) bool { _, ok1 := x.(error) _, ok2 := y.(error) return ok1 && ok2 }, cmp.Comparer(func(x, y interface{}) bool { xe := x.(error) ye := y.(error) if xe == nil || ye == nil { return xe == nil && ye == nil } return xe.Error() == ye.Error() })) // RuntimeObjectIgnoreRvTypeMeta compares two kubernetes objects, ignoring their resource // version and TypeMeta. It is what you want 99% of the time. RuntimeObjectIgnoreRvTypeMeta = cmp.Comparer(func(x, y runtime.Object) bool { xCopy := x.DeepCopyObject() yCopy := y.DeepCopyObject() CleanRVAndTypeMeta(xCopy) CleanRVAndTypeMeta(yCopy) return cmp.Diff(xCopy, yCopy) == "" }) )
Functions ¶
func ArtifactDir ¶
func ArtifactDir(t TestingTInterface) string
ArtifactDir determines where artifacts should for for a test case.
func CleanRVAndTypeMeta ¶
func CompareWithFixture ¶
CompareWithFixture will compare output with a test fixture and allows to automatically update them by setting the UPDATE env var. If output is not a []byte or string, it will get serialized as yaml prior to the comparison. The fixtures are stored in $PWD/testdata/prefix${testName}.yaml
func GetFreePort ¶
func GetFreePort(t TestingTInterface) string
GetFreePort asks the kernel for a free open port that is ready to use.
func ReadFromFixture ¶
ReadFromFixture reads an input fixture file and returns the data
func Vault ¶
Vault constructs a running Vault instance ready for testing. It returns its addess. VaultTestingRootToken is the initial root token.
func WaitForHTTP200 ¶
func WaitForHTTP200(addr, command string, waitFor int64, t TestingTInterface)
WaitForHTTP200 waits waitFor seconds for the provided addr to return a http/200. If that doesn't happen, it will call t.Fatalf
Types ¶
type Accessory ¶
type Accessory struct {
// contains filtered or unexported fields
}
func NewAccessory ¶
func (*Accessory) ClientFlags ¶
ClientFlags exposes the port on which we are serving content and any other flags that are needed for clients to consume this accessory.
func (*Accessory) Ready ¶
func (a *Accessory) Ready(t TestingTInterface, o ...ReadyOption)
Ready returns when the accessory process is ready to serve data.
func (*Accessory) Run ¶
func (a *Accessory) Run(t TestingTInterface)
Run begins the accessory process. this call is not blocking. Because testing.T does not allow to call Fatalf in a distinct goroutine, this will use Errorf instead.
func (*Accessory) RunFromFrameworkRunner ¶
func (a *Accessory) RunFromFrameworkRunner(t TestingTInterface, parentCtx context.Context, stream bool)
RunFromFrameworkRunner begins the accessory process. Only test/e2e/framework.Run is allowed to call this as it required additional synchronization or your tests might pass incorrectly.
type ReadyOption ¶
type ReadyOption func(*ReadyOptions)
type ReadyOptions ¶
type ReadyOptions struct { // ReadyURL is the url to GET to check for readyness. Defaults to // http://127.0.0.1:${HEALTH_PORT}/healthz/ready ReadyURL string WaitFor int64 }
type T ¶
T allows us to provide a similar UX to the testing.T while doing so in a multi-threaded context. The Go unit testing framework only allows the top-level goroutine to call FailNow so it's important to provide this interface to all the routines that want to be able to control the test execution flow.
type TestingTInterface ¶
type TestingTInterface interface { Cleanup(f func()) Deadline() (deadline time.Time, ok bool) Error(args ...interface{}) Errorf(format string, args ...interface{}) Fail() FailNow() Failed() bool Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Helper() Log(args ...interface{}) Logf(format string, args ...interface{}) Name() string Parallel() Skip(args ...interface{}) SkipNow() Skipf(format string, args ...interface{}) Skipped() bool TempDir() string }
TestingTInterface contains the methods that are implemented by both our T and testing.T