Documentation
¶
Index ¶
- Variables
- func Exec(tb testing.TB, wait string, runner func(tb testing.TB, cmd *exec.Cmd)) (string, error)
- func Integration(tb testing.TB)
- func Logger(tb testing.TB) *zap.Logger
- func MultipliedDuration(tb testing.TB, d time.Duration) time.Duration
- func MultipliedInt(tb testing.TB, i int) int
- func Random(tb testing.TB) string
- func Verbose(tb testing.TB) bool
- func WithMultiplier(tb testing.TB, f float64, fn func(tb testing.TB))
Constants ¶
This section is empty.
Variables ¶
var TestMultiplier = "1.0"
TestMultiplier can be used to increase the default duration or integers used during test runs when waiting for time-sensitive values to be returned. It defaults to a multiplier of 1.0.
This is specifically useful on slower environments like a CI server.
Functions ¶
func Exec ¶
Exec runs the current executed test as an external command, setting the `RUN_WITH_EXEC` environment variable to `1`, waiting for the `wait` string to be printed on stderr (unless empty), executes the `runner` function, and returns the stderr output and the exit status of the command.
func Integration ¶
Integration skips the test if the `-short` flag is specified. It also enforces the test name to starts with `Integration`, this allows to run _only_ integration tests using `-run '^TestIntegration'` or `-bench '^BenchmarkIntegration`.
func Logger ¶
Logger returns a Zap logger instance to use during testing. It returns logs in a user-friendly format, reporting anything above warn level.
DEPRECATED: this is now supported by Zap itself, since version `1.9.0`.
See: https://github.com/uber-go/zap/pull/518
func MultipliedDuration ¶
MultipliedDuration returns the provided duration, multiplied by the configured `TestMultiplier` variable.
func MultipliedInt ¶
MultipliedInt returns the provided int, multiplied by the configured `TestMultiplier` variable. `TestMultiplier` is a float, but is converted to the next logical integer (ceiling).
func Verbose ¶
Verbose returns true if the `testing.Verbose` flag returns true, or if the environment variable `CI` is set to any value. This allows you to see more verbose error reporting locally when running `go test -v ./...`, or on the CI by default.
func WithMultiplier ¶
WithMultiplier runs the passed in function with the configured test multiplier. Note that this function is NOT thread-safe. If you call this function in tests that set `Parallel()`, you might get unexpected results.
Types ¶
This section is empty.