Documentation
¶
Index ¶
- func Contains(substring string) containsChecker
- func HasLen[T any](length int) hasLenChecker[T]
- func Is[T comparable](value T) isChecker[T]
- func IsNull[T any]() isNullChecker[T]
- func Matches(pattern string) matchesChecker
- func Not[T any](checker Checker[T]) notChecker[T]
- func OneOf[T comparable](values ...T) oneOfChecker[T]
- type Assertion
- func (a *Assertion) Body(checkers ...Checker[string]) *Assertion
- func (a *Assertion) Check()
- func (a *Assertion) Consistently(timeout ...time.Duration) *Assertion
- func (a *Assertion) Eventually(timeout ...time.Duration) *Assertion
- func (a *Assertion) Hint(help string) *Assertion
- func (a *Assertion) JSON(path string, checkers ...Checker[string]) *Assertion
- func (a *Assertion) Status(checkers ...Checker[int]) *Assertion
- type Checker
- type Do
- func (do *Do) Cancel()
- func (do *Do) Concurrently(n int, fn func(i int))
- func (do *Do) DELETE(node, path string, args ...any) *Assertion
- func (do *Do) Done()
- func (do *Do) GET(node, path string, args ...any) *Assertion
- func (do *Do) Kill(name string)
- func (do *Do) MockNode(name, port string)
- func (do *Do) PATCH(node, path string, args ...any) *Assertion
- func (do *Do) POST(node, path string, args ...any) *Assertion
- func (do *Do) PUT(node, path string, args ...any) *Assertion
- func (do *Do) Restart(name string, sig ...syscall.Signal)
- func (do *Do) Start(name string)
- func (do *Do) Stop(name string)
- type H
- type JSONFieldChecker
- type Node
- type Option
- func WithAssertTimeout(d time.Duration) Option
- func WithCluster(n int) Option
- func WithCommand(cmd string) Option
- func WithNodeShutdownTimeout(d time.Duration) Option
- func WithNodeStartTimeout(d time.Duration) Option
- func WithPollInterval(d time.Duration) Option
- func WithRequestTimeout(d time.Duration) Option
- func WithWorkingDir(dir string) Option
- type Suite
- type TestFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(substring string) containsChecker
Contains creates a checker that checks if actual contains the substring.
func HasLen ¶
HasLen creates a checker that validates the length of arrays, slices, maps, channels, or strings.
func Is ¶
func Is[T comparable](value T) isChecker[T]
Is creates a checker that validates exact equality.
func IsNull ¶
func IsNull[T any]() isNullChecker[T]
IsNull creates a checker that checks if a value is nil.
func Matches ¶
func Matches(pattern string) matchesChecker
Matches creates a checker that checks if actual matches the regex pattern.
func OneOf ¶
func OneOf[T comparable](values ...T) oneOfChecker[T]
OneOf creates a checker that accepts any of the provided values.
Types ¶
type Assertion ¶ added in v0.4.0
type Assertion struct {
// contains filtered or unexported fields
}
Assertion describes an HTTP request and the conditions its response must satisfy.
func (*Assertion) Body ¶ added in v0.4.0
Body adds expected HTTP response body checkers. All checkers must pass.
func (*Assertion) Check ¶ added in v0.4.0
func (a *Assertion) Check()
Check executes the assertion and panics on failure.
func (*Assertion) Consistently ¶ added in v0.4.0
Consistently configures the assertion to verify success for the entire duration.
func (*Assertion) Eventually ¶ added in v0.4.0
Eventually configures the assertion to retry until success or timeout.
type Checker ¶
type Checker[T any] interface { // Check returns true if actual satisfies this checker's condition. Check(actual T) bool // Expected returns a human-readable description of what was expected. Expected() string }
Checker is a composable predicate used in assertions to validate actual values against expected conditions.
type Do ¶
type Do struct {
// contains filtered or unexported fields
}
Do provides the test harness and acts as the test runner.
func (*Do) Concurrently ¶
Concurrently runs fn n times in parallel, passing each invocation a 1-based index.
type JSONFieldChecker ¶
type JSONFieldChecker struct {
// contains filtered or unexported fields
}
JSONFieldChecker pairs a gjson path with a checker for that field.
func JSON ¶
func JSON(path string, checker Checker[string]) JSONFieldChecker
JSON creates a checker that extracts a JSON field at the given path and validates it.
func (JSONFieldChecker) Check ¶
func (m JSONFieldChecker) Check(actual string) bool
func (JSONFieldChecker) Expected ¶
func (m JSONFieldChecker) Expected() string
type Node ¶ added in v0.4.0
type Node struct {
// contains filtered or unexported fields
}
Node represents a running node.
type Option ¶ added in v0.4.0
type Option func(*config)
Option configures a Suite.
func WithAssertTimeout ¶ added in v0.4.0
WithAssertTimeout sets the default timeout for Eventually and Consistently.
func WithCluster ¶ added in v0.4.0
WithCluster declares N nodes named n1, n2, ... nN.
func WithCommand ¶ added in v0.4.0
WithCommand sets the script or binary used to start each node.
func WithNodeShutdownTimeout ¶ added in v0.4.0
WithNodeShutdownTimeout sets how long to wait for a node to exit before sending SIGKILL.
func WithNodeStartTimeout ¶ added in v0.4.0
WithNodeStartTimeout sets how long to wait for a node to accept connections after starting.
func WithPollInterval ¶ added in v0.4.0
WithPollInterval sets how often Eventually and Consistently poll.
func WithRequestTimeout ¶ added in v0.4.0
WithRequestTimeout sets the HTTP client timeout per request.
func WithWorkingDir ¶ added in v0.4.0
WithWorkingDir sets the base directory for test run artifacts and node data.
type Suite ¶
type Suite struct {
// contains filtered or unexported fields
}
Suite represents a test suite with setup and test functions.