Documentation
¶
Overview ¶
Package test implements helpers for testing.
Index ¶
- func AllocateFreePorts(n int) ([]int, error)
- func Cleanup()
- func NewSpace() (tempDir string, deferFunc func(), err error)
- func SetupModules(flags []string, units ...run.Unit) func()
- func Space(t *require.Assertions) (tempDir string, deferFunc func())
- type ECAssertion
- func (a ECAssertion) Should(matcher gomegatypes.GomegaMatcher, optionalDescription ...interface{}) bool
- func (a ECAssertion) ShouldNot(matcher gomegatypes.GomegaMatcher, optionalDescription ...interface{}) bool
- func (a ECAssertion) WithPolling(polling time.Duration) ECAssertion
- func (a ECAssertion) WithTimeout(timeout time.Duration) ECAssertion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateFreePorts ¶
AllocateFreePorts finds n available ports Copied from https://github.com/tendermint/tendermint/issues/3682
func Cleanup ¶ added in v0.6.0
func Cleanup()
Cleanup removes all files and directories created by the test.
func NewSpace ¶
NewSpace create a tmp dir and returns the path and its clear function. It will return any error when failed to create this dir.
func SetupModules ¶ added in v0.3.0
SetupModules wires input modules to build a testing ready runtime.
func Space ¶
func Space(t *require.Assertions) (tempDir string, deferFunc func())
Space create a tmp dir and returns the path and its clear function. It will be panic when encountering some errors.
Types ¶
type ECAssertion ¶ added in v0.11.0
type ECAssertion struct {
// contains filtered or unexported fields
}
ECAssertion pairs a gomega Eventually with a following Consistently. It mirrors gomega.Eventually's layout: intervals may be supplied up front or via the fluent WithTimeout/WithPolling methods, and the matcher is applied via Should/ShouldNot.
func EventuallyConsistently ¶ added in v0.11.0
func EventuallyConsistently(actual interface{}, intervals ...interface{}) ECAssertion
EventuallyConsistently returns an assertion that first waits for actual to satisfy the matcher (Eventually) and then requires it to keep satisfying the matcher for a stability window (Consistently). Pairing convergence with a stability window catches transient states that briefly match and then regress, which a lone Eventually would accept.
intervals follow gomega.Eventually semantics — (timeout) or (timeout, polling). They can also be set fluently via WithTimeout/WithPolling. When the timeout is omitted it defaults to flags.EventuallyTimeout. The Consistently window always runs and reuses the polling interval, if any; its length adapts to how the Eventually phase converged — flags.QuickStabilityTimeout after a first-try success, flags.StabilityTimeout after a retried convergence (see Should).
func (ECAssertion) Should ¶ added in v0.11.0
func (a ECAssertion) Should(matcher gomegatypes.GomegaMatcher, optionalDescription ...interface{}) bool
Should asserts the matcher is reached and then held. It returns true only when both the Eventually and the Consistently assertion pass, matching the bool return of gomega's Should. optionalDescription is forwarded to both assertions.
The Consistently phase always runs, but its window is adaptive. When the Eventually phase succeeds on its very first evaluation, the state was already settled before the assertion began, so a short flags.QuickStabilityTimeout window (still a dozen re-samples) suffices to reject a one-off lucky match. Only assertions that had to retry — proof of an in-flight async process that could still regress — pay the full flags.StabilityTimeout window. This keeps the regression guard everywhere without charging every static assertion in the large query tables for a full window.
func (ECAssertion) ShouldNot ¶ added in v0.11.0
func (a ECAssertion) ShouldNot(matcher gomegatypes.GomegaMatcher, optionalDescription ...interface{}) bool
ShouldNot asserts the matcher is avoided and then kept avoided. It returns true only when both assertions pass, matching the bool return of gomega's ShouldNot. optionalDescription is forwarded to both assertions. The stability window is adaptive — see Should.
func (ECAssertion) WithPolling ¶ added in v0.11.0
func (a ECAssertion) WithPolling(polling time.Duration) ECAssertion
WithPolling overrides the polling interval used by both the Eventually and the Consistently phase, mirroring gomega.AsyncAssertion.WithPolling.
func (ECAssertion) WithTimeout ¶ added in v0.11.0
func (a ECAssertion) WithTimeout(timeout time.Duration) ECAssertion
WithTimeout overrides the Eventually convergence timeout, mirroring gomega.AsyncAssertion.WithTimeout.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package flags implements injected flags to run tests.
|
Package flags implements injected flags to run tests. |
|
Package flow implements mockers for testing flow.
|
Package flow implements mockers for testing flow. |
|
Package gmatcher provides custom Gomega matchers.
|
Package gmatcher provides custom Gomega matchers. |
|
Package helpers implements several helpers for testing.
|
Package helpers implements several helpers for testing. |
|
Package measure implements helpers to load schemas for testing.
|
Package measure implements helpers to load schemas for testing. |
|
Package property implements helpers to load schemas for testing.
|
Package property implements helpers to load schemas for testing. |
|
Package query provides functions for analyzing and collecting metrics.
|
Package query provides functions for analyzing and collecting metrics. |
|
replicated
|
|
|
measure
Package replicatedmeasure implements helpers to load replicated schemas for testing.
|
Package replicatedmeasure implements helpers to load replicated schemas for testing. |
|
stream
Package replicatedstream implements helpers to load replicated schemas for testing.
|
Package replicatedstream implements helpers to load replicated schemas for testing. |
|
trace
Package trace implements helpers to load replicated schemas for testing.
|
Package trace implements helpers to load replicated schemas for testing. |
|
Package setup implements a real env in which to run tests.
|
Package setup implements a real env in which to run tests. |
|
Package stream implements helpers to load schemas for testing.
|
Package stream implements helpers to load schemas for testing. |
|
Package trace implements helpers to load schemas for testing.
|
Package trace implements helpers to load schemas for testing. |