Documentation
¶
Index ¶
- func DoRequest(t *testing.T, method, url string) *http.Response
- func ParseAllow(h string) map[string]struct{}
- func RegisterOK(t *testing.T, d drv.Drv, method, pattern string, h http.Handler)
- func RequireBody(t *testing.T, resp *http.Response, want string)
- func RequireNoErr(t *testing.T, err error)
- func RequireStatus(t *testing.T, resp *http.Response, want int)
- func RunAdapter(t *testing.T, f AdapterFactory)
- func RunDriver(t *testing.T, f DriverFactory)
- func RunDriverBenchmarks(b *testing.B, f DriverBenchFactory)
- func RunDriverSmoke(t *testing.T, f DriverFactory)
- func SortedKeys(m map[string]struct{}) []string
- type AdapterFactory
- type DriverBenchFactory
- type DriverFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAllow ¶
func RequireNoErr ¶
func RunAdapter ¶
func RunAdapter(t *testing.T, f AdapterFactory)
RunAdapter executes the adapter conformance suite against the provided factory. Adapter conformance requires RegistryProvider.
func RunDriver ¶
func RunDriver(t *testing.T, f DriverFactory)
RunDriver executes the driver conformance suite against the provided factory.
This is the entry point used by driver packages (or their tests) to validate they match the jetwarp driver contract.
Example usage:
suite.RunDriver(t, suite.DriverFactory{
Name: "mock",
New: func(t *testing.T) driver.Drv {
return testkit.NewMockDriver(...)
},
})
Subtest naming uses "driver=<Name>" so multiple drivers can be executed in a single `go test` run.
func RunDriverBenchmarks ¶
func RunDriverBenchmarks(b *testing.B, f DriverBenchFactory)
RunDriverBenchmarks runs the benchmark battery for a driver factory.
Call it from a Benchmark function:
func BenchmarkDriver_MockFull(b *testing.B) {
suite.RunDriverBenchmarks(b, suite.DriverBenchFactory{ ... })
}
func RunDriverSmoke ¶
func RunDriverSmoke(t *testing.T, f DriverFactory)
RunDriverSmoke runs a practical, "real-world-ish" smoke battery against a driver.
Design goals:
- Portable across drivers (capability-driven, minimal router assumptions).
- Exercises typical usage patterns that conformance tests may not stress:
- a small route tree
- scope mounting semantics (parent + child routes working together)
- param extraction
- "weird" param-suffix case (infix prefix+suffix within a segment)
- MethodAny, if supported
- concurrency (many simultaneous requests after registration)
Non-goals:
- It is NOT a replacement for conformance tests.
- It does not enforce "405 + Allow" as a hard requirement across all routers. Some routers respond 404 for unknown methods, others respond 405 with varying Allow behavior. We treat 405/Allow checks as "best effort": if we observe 405, we validate Allow is useful.
func SortedKeys ¶
Types ¶
type AdapterFactory ¶
type AdapterFactory struct {
// New constructs a new adapter instance for the test.
//
// The returned adapter must be non-nil and ready to accept route registrations.
// It must not share route registrations with instances returned for other subtests.
New func(t *testing.T) adapter.Adapter
// Name is used in subtest names for diagnostics. Example: "core+mock", "chi", "stdlib".
Name string
}
AdapterFactory constructs a fresh adapter instance for each subtest.
type DriverBenchFactory ¶
type DriverBenchFactory struct {
// New constructs a new driver instance. Must return non-nil.
New func(tb testing.TB) drv.Drv
// Name labels the benchmark group (e.g., "mock-full", "chi", "stdlib").
Name string
}
DriverBenchFactory constructs a fresh driver instance for each benchmark.
It mirrors DriverFactory but accepts testing.TB so it works for *testing.B and *testing.T. Each call must return an isolated driver instance (no shared route registrations between benches).
type DriverFactory ¶
type DriverFactory struct {
// New constructs a new driver instance for the test.
//
// The returned driver must be non-nil and ready to accept route registrations.
// It must not share route registrations with instances returned for other subtests.
New func(t *testing.T) drv.Drv
// Name is used in subtest names for diagnostics. Example: "mock", "chi", "stdlib".
Name string
}
DriverFactory constructs a fresh driver instance for each subtest.
The suite assumes each New(...) returns an isolated driver instance so tests do not interfere via shared route registrations.
If a real driver is stateful (e.g., because the underlying router shares global state), wrap it so that New() produces a fresh instance (or resets state) per call.
Name is used to label subtests and to identify the driver in skip logs.