Documentation
¶
Index ¶
Constants ¶
View Source
const ExpectPreconditionsMet = "DEVNET_EXPECT_PRECONDITIONS_MET"
Variables ¶
View Source
var ( // RootContext is the context that is used for the root of the test suite. // It should be set for good before any tests are run. RootContext = context.Background() )
Functions ¶
func RunParallel ¶
RunParallel runs the test-function, for each of the given elements, in parallel. This awaits the result of all sub-tests to complete, by grouping everything into a regular sub-test.
Types ¶
type CommonT ¶
type CommonT interface {
Errorf(format string, args ...interface{})
FailNow()
TempDir() string
Cleanup(fn func())
Logf(format string, args ...any)
Helper()
Name() string
Logger() Logger
Tracer() trace.Tracer
Ctx() context.Context
Require() *require.Assertions
}
CommonT is a subset of testing.T, extended with a few common utils. This interface should not be used directly. Instead, use T in test-scope, or P when operating at package level.
This CommonT interface is minimal enough such that it can be implemented by tooling, and a *testing.T can be used with minimal wrapping.
type P ¶
type P interface {
CommonT
// TempDir creates a temporary directory, and returns the file-path.
// This directory is cleaned up at the end of the package,
// and can be shared safely between tests that run in that package scope.
TempDir() string
// Cleanup runs the given function at the end of the package-scope.
// This function will clean-up once the package-level testing is fully complete.
// These resources can thus be shared safely between tests.
Cleanup(fn func())
// Close closes the testing handle. This cancels the context and runs all cleanup.
Close()
// contains filtered or unexported methods
}
P is used by the preset package and system backends as testing interface, to host package-wide resources.
type T ¶
type T interface {
CommonT
// TempDir creates a temporary directory, and returns the file-path.
// This directory is cleaned up at the end of the test, and must not be shared between tests.
TempDir() string
// Cleanup runs the given function at the end of the test-scope,
// or at the end of the sub-test (if this is a nested test).
// This function will clean-up before the package-level testing scope may be complete.
// Do not use the test-scope cleanup with shared resources.
Cleanup(fn func())
// Run runs the given function in as a sub-test.
Run(name string, fn func(T))
// Ctx returns a context that will be canceled at the end of this (sub) test-scope,
// and inherits the context of the parent-test-scope.
Ctx() context.Context
// Parallel signals that this test is to be run in parallel with (and only with) other parallel tests.
Parallel()
// Skip is equivalent to Log followed by SkipNow.
Skip(args ...any)
// Skipped reports whether the test was skipped.
Skipped() bool
// Skipf is equivalent to Logf followed by SkipNow.
Skipf(format string, args ...any)
// SkipNow marks the test as skipped and stops test execution.
// It is remapped to FailNow if the env var DEVNET_EXPECT_PRECONDITIONS_MET is set to true.
SkipNow()
// Gate provides everything that Require does, but skips instead of fails the test upon error.
Gate() *require.Assertions
// Deadline reports the time at which the test binary will have
// exceeded the timeout specified by the -timeout flag.
//
// The ok result is false if the -timeout flag indicates “no timeout” (0).
Deadline() (deadline time.Time, ok bool)
// contains filtered or unexported methods
}
Click to show internal directories.
Click to hide internal directories.