Help us shape the future of Go! Take the 2026 Go Developer Survey

testkit

package module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

README

nexssp/testkit

Go Reference CI License

Test the real boundary, not a mock of it.

nexssp/testkit is a Go testing toolkit for real HTTP integration tests, black-box E2E tests, SSE streams, load, chaos, and JSON-RPC/stdio transports.

It uses the standard testing package and standard net/http interfaces. It does not require a third-party mock framework.

Two packages, two scopes

Testing a Nexssp system means testing two different layers, and there are two different packages for that:

Layer Package What it owns
HTTP, SSE, JSON-RPC, load, chaos github.com/nexssp/testkit (this package) Wire-protocol test harnesses against a live http.Handler, a running process, or an in-memory net.Pipe
Action primitives github.com/nexssp/kernel/xtest, .../xtest/ktest Polling (Eventually), golden files, call tracing, action fakes, scripted responses, hook recording, concurrency barriers, benchmark helpers, context and error assertions

Rule of thumb:

  • If the test touches HTTP, SSE, JSON-RPC, a network socket, or a load generator — it belongs in testkit.
  • If the test touches action.BuiltAction, iter.Seq2, hooks, xctx, or xerr — it belongs in kernel/xtest or kernel/xtest/ktest.

There is no overlap. testkit does not re-export kernel helpers, and kernel/xtest does not touch net/http.

What testkit provides

Target Constructor or package Scope
nexssp/kernel actions testkit.New In-process HTTP integration with mounted actions
Any Go router or handler testkit.NewWithHandler Router and middleware integration
Running local, LAN, container, staging, or production URL testkit.NewE2E Black-box HTTP E2E
JSON-RPC or stdio server testkit/rpc Line-delimited JSON-RPC over an in-memory pipe
Action fault injection testkit/chaos, testkit.WithChaos Stochastic latency, errors, and panics
HTTP load testkit.LoadTest, testkit.StartBackgroundLoad In-process stress and profiling

What kernel/xtest provides

Use these directly. They are not re-exported here.

Need API
Wait for arbitrary state xtest.Eventually(t, timeout, cond)
Custom poll interval xtest.EventuallyEvery(t, timeout, interval, cond)
Error-returning variants xtest.EventuallyE, xtest.EventuallyEveryE
Wait for a value xtest.WaitForValue[T](t, timeout, want, get)
Golden-file snapshot xtest.GoldenJSON(t, name, got) with -xtest.update
Assert callback order ktest.Trace, Trace.RequireSequence, RequireOrder
Concurrency barrier ktest.Simulate(t, act, req, n, assertFn)
Structural action contracts ktest.AssertContracts(t, actions)
Scripted action responses ktest.Script, ktest.Success, ktest.Failure
Record retry / cache / coalesce ktest.Recorder[Req, Res]
Action stubs ktest.Fake, ktest.Echo, ktest.Returns, ktest.Fails, ktest.Sequence, ktest.Flaky
Single-action run ktest.Run(tb, act, ctx, req)
Action benchmark ktest.BenchAction(b, act, req)
xctx-populated test contexts ktest.Ctx, ktest.CtxWithAuth, ...
xerr assertions ktest.RequireNoError, ktest.RequireErrorKind, ...
Parallel runner xtest.RunParallel(tb, n, fn)
Goroutine leak check xtest.RequireNoGoroutineLeak(tb, base, timeout)

Installation

go get github.com/nexssp/testkit@latest
go get github.com/nexssp/kernel@latest

Quick decision guide

Choose a constructor
// Kernel actions, in memory.
suite := testkit.New(t, GetUser, CreateOrder)

// Any standard net/http.Handler.
suite := testkit.NewWithHandler(t, mux)

// A running process, container, LAN machine, or staging deployment.
suite := testkit.NewE2E(t, "http://127.0.0.1:8080")
Choose an assertion
Requirement API Package
One synchronous HTTP request suite.GET(...).Do().ExpectOK() testkit
Decode one response response.Into(&dst) testkit
Inspect nested JSON response.HasField("data.id", value) testkit
Poll an HTTP JSON endpoint testkit.WaitForJSON(...) testkit
Wait for a named SSE event stream.WaitFor(...) testkit
Wait for an SSE substring stream.WaitForData(...) testkit
Match structured SSE criteria stream.WaitForSSE(...) testkit
Probe all action routes over HTTP testkit.RunSmokeTests(...) testkit
Test JSON-RPC/stdio testkit/rpc testkit
Wait for a non-HTTP condition xtest.Eventually(...) kernel/xtest
Snapshot a value as golden JSON xtest.GoldenJSON(...) kernel/xtest
Assert callback order ktest.Trace kernel/xtest/ktest
Force N goroutines through a barrier ktest.Simulate(...) kernel/xtest/ktest
Check structural action invariants ktest.AssertContracts(...) kernel/xtest/ktest

Cheatsheet

// Immediate HTTP assertion.
suite.GET("/healthz").Do().ExpectOK()

// Request options.
suite.POST("/v1/orders").
    WithJSON(map[string]any{"sku": "A1"}).
    WithBearerToken("token").
    WithTenant("tenant-1").
    Do().
    ExpectCreated()

// Typed response.
var status StatusResponse
suite.GET("/api/status").Do().ExpectOK().Into(&status)

// Eventually consistent HTTP state.
status = testkit.WaitForJSON[StatusResponse](
    t,
    20*time.Second,
    250*time.Millisecond,
    func() (*testkit.Response, error) {
        return suite.GET("/api/status").DoE()
    },
    func(value StatusResponse) bool {
        return value.State == "completed"
    },
)

// SSE event matching.
stream := suite.ListenSSE("/api/events")
t.Cleanup(stream.Close)
event := stream.WaitForSSE(t, 20*time.Second, func(event testkit.SSEEvent) bool {
    return event.Event == "docker" && strings.Contains(event.Data, "completed")
})
_ = event

// Non-HTTP eventual condition (kernel xtest).
xtest.Eventually(t, 10*time.Second, func() bool {
    return service.IsReady()
})

1. Testing kernel actions

testkit.New mounts actions on an in-memory httptest.Server, applies the test context bridge, and registers cleanup with t.Cleanup.

package orders_test

import (
    "context"
    "testing"

    "github.com/nexssp/kernel/action"
    "github.com/nexssp/testkit"
    "github.com/nexssp/transport/thttp"
)

type UserDTO struct {
    ID    string `json:"id" path:"id"`
    Email string `json:"email"`
}

func TestGetUser(t *testing.T) {
    getUser := action.New("user.get", func(_ context.Context, req UserDTO) (UserDTO, error) {
        return UserDTO{ID: req.ID, Email: "admin@nexss.com"}, nil
    }).Route(thttp.GET("/v1/users/{id}")).Build()

    suite := testkit.New(t, getUser)
    suite.GET("/v1/users/usr-42").
        Do().
        ExpectOK().
        HasField("id", "usr-42").
        HasField("email", "admin@nexss.com")
}

2. Testing any http.Handler

No kernel dependency is required. NewWithHandler works with the standard library and routers such as Chi, Gin, and Echo.

func TestHealth(t *testing.T) {
    mux := http.NewServeMux()
    mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, _ *http.Request) {
        w.Header().Set("Content-Type", "application/json")
        _, _ = w.Write([]byte(`{"status":"healthy"}`))
    })

    suite := testkit.NewWithHandler(t, mux)
    suite.GET("/healthz").Do().ExpectOK().HasField("status", "healthy")
}

3. Black-box E2E testing

NewE2E uses the same request and assertion API against a running service.

func TestStagingStatus(t *testing.T) {
    suite := testkit.NewE2E(t, "https://staging-api.example.com")

    suite.GET("/v1/system/status").
        WithHeader("X-Api-Key", os.Getenv("STAGING_API_KEY")).
        Do().
        ExpectOK().
        HasField("environment", "staging")
}

For a local LAN service:

JUMALU_URL=http://192.168.1.42:8080 go test -tags=integration -v ./integration/...

Use E2E tests for the real process, configuration, persistence, Docker, network, and provider boundaries. Keep them separate from fast in-process tests.

4. HTTP requests and assertions

suite.POST("/v1/invoices").
    WithQuery("draft", "true").
    WithQueries(map[string]string{"currency": "USD"}).
    WithHeader("X-Trace-ID", "trace-123").
    WithBearerToken("jwt-token").
    WithTenant("tenant-corp").
    WithCookie("session_id", "sess-abc").
    WithJSON(map[string]any{
        "customer": "Acme Corp",
        "amount":   1250.50,
    }).
    Do().
    ExpectCreated()

For multipart uploads:

suite.POST("/v1/documents/upload").
    WithMultipartFile("file", "invoice.pdf", []byte("%PDF-1.4...")).
    Do().
    ExpectCreated()

Available response operations:

ExpectStatus(code)
ExpectSuccess()
ExpectOK()
ExpectCreated()
ExpectBadRequest()
ExpectUnauthorized()
ExpectForbidden()
ExpectNotFound()
ExpectHeader(name, value)
HasField("data.items.0.sku", "PROD-99")
ExpectArrayLen("data.items", 3)
ContainsString("Acme Corp")
Into(&typedValue)
ExpectErrorKind(kind, message)

HasField uses dot-separated paths and numeric array indexes. Use Into when a typed response is more readable or when the test needs several fields.

DoE returns an error instead of failing the test immediately and is useful in polling functions:

response, err := suite.GET("/healthz").DoE()

5. Asynchronous HTTP and SSE assertions

WaitForJSON

WaitForJSON polls an HTTP endpoint that exposes eventually consistent state. The request factory must build a fresh request for each attempt. Request and JSON-decoding errors are retried; if the timeout expires, the last observed error is included in the failure message.

type StatusResponse struct {
    State string `json:"state"`
}

status := testkit.WaitForJSON[StatusResponse](
    t,
    20*time.Second,
    250*time.Millisecond,
    func() (*testkit.Response, error) {
        return suite.GET("/api/status").DoE()
    },
    func(value StatusResponse) bool {
        return value.State == "completed"
    },
)

For non-HTTP polling, use xtest.Eventually or xtest.EventuallyEvery from github.com/nexssp/kernel/xtest. Do not use polling to hide a deterministic failure.

SSE
stream := suite.ListenSSE("/events/telemetry")
t.Cleanup(stream.Close)

suite.POST("/v1/trigger-event", map[string]string{"msg": "ping"}).
    Do().
    ExpectOK()

// Named event.
event := stream.WaitFor(t, "message", 2*time.Second)

// Data substring.
event = stream.WaitForData(t, "ping", 2*time.Second)

// Structured predicate.
event = stream.WaitForSSE(t, 2*time.Second, func(event testkit.SSEEvent) bool {
    return event.Event == "message" && strings.Contains(event.Data, "ping")
})

For MCP-style SSE handshakes:

endpoint := stream.Endpoint(t, 2*time.Second)

For POST plus SSE protocols such as MCP Streamable HTTP or A2A, use ListenSSEWithRequest.

6. Route smoke testing

RunSmokeTests discovers mounted action routes, synthesizes minimal payloads, substitutes path parameters, and fails on unhandled 5xx responses.

func TestAllRoutes(t *testing.T) {
    testkit.RunSmokeTests(t, []action.AnyAction{
        CreateOrder,
        GetOrder,
        ListOrders,
    })
}

A 2xx, 4xx, or other intentional non-5xx response passes. This verifies that endpoints do not panic or fail through an unhandled server error; it does not replace behavioral endpoint tests.

7. Load and latency testing

LoadTest runs in-process traffic and reports request count, RPS, error rate, and latency percentiles.

result := suite.LoadTest(t, testkit.LoadConfig{
    Concurrency: 16,
    Duration:    3 * time.Second,
    Method:      http.MethodGet,
    Path:        "/v1/orders/ord-1",
})

t.Logf("requests=%d rps=%.2f errors=%.2f%% p50=%v p95=%v p99=%v",
    result.TotalRequests,
    result.RPS,
    result.ErrorRate*100,
    result.P50,
    result.P95,
    result.P99,
)

StartBackgroundLoad is useful while collecting profiles or inspecting metrics:

stop := suite.StartBackgroundLoad(testkit.LoadConfig{
    Concurrency: 8,
    Method:      http.MethodGet,
    Path:        "/v1/orders/ord-1",
})
defer stop()

Treat load-test thresholds as environment-specific measurements, not universal guarantees.

8. Chaos and fault injection

testkit/chaos injects controlled delay, errors, and panics into action execution.

actions := testkit.WithChaos([]action.AnyAction{CreateOrder}, chaos.Config{
    Enabled:   true,
    ErrorRate: 0.25,
    MaxDelay:  150 * time.Millisecond,
    PanicRate: 0.02,
})

suite := testkit.New(t, actions)
suite.POST("/v1/orders", map[string]any{"sku": "A"}).
    Do().
    ExpectSuccess()

Use chaos tests to verify retry, timeout, circuit-breaker, panic-recovery, and error-boundary behavior. Keep randomness bounded and use assertions that tolerate the configured fault rate.

9. JSON-RPC and stdio transports

Use testkit/rpc for line-delimited JSON-RPC transports such as MCP stdio. It uses an in-memory net.Pipe and a real JSON-RPC client.

func TestMCPStdio(t *testing.T) {
    client := rpc.DialJSONRPC(t, func(ctx context.Context, in io.Reader, out io.Writer) error {
        return mcpServer.Serve(ctx, in, out)
    })

    response := client.Call("tools/list", nil, 1)

    var result struct {
        Tools []struct {
            Name string `json:"name"`
        } `json:"tools"`
    }
    response.BindResult(t, &result)

    if len(result.Tools) == 0 {
        t.Fatal("expected at least one tool")
    }
}

The RPC client supports:

client.Call(method, params, id)
client.Notify(method, params)
client.CallRaw(rawJSON)
response.BindResult(t, &destination)
response.Error

Testing guidance

Keep tests in layers:

  1. Unit tests for pure functions and deterministic action behavior.
  2. In-process integration tests with New or NewWithHandler.
  3. Black-box E2E tests with NewE2E against a real process or deployment.
  4. Load and chaos tests as explicit, separately named test groups.

Use build tags or environment gates for tests requiring Docker, external providers, a LAN service, or a running binary:

go test ./...
go test -race ./...
go test -tags=integration -v ./integration/...

Avoid putting credentials in source code or logs. Use environment variables and explicit test configuration. A trusted-LAN E2E test is not an authorization test and must not be presented as one.

Project status and performance claims

testkit provides testing primitives and measurement tools. It does not guarantee that an application is production-ready, zero-allocation on every path, or capable of a particular scale. Those properties depend on the application, dependencies, deployment, workload, and measured results.

Use benchmarks, race tests, load tests, and production-like E2E tests to establish claims for a specific system.

License

Apache License 2.0. See LICENSE for details.

Documentation

Overview

Package testkit provides deterministic, fluent test harnesses for both nexssp actions and standard Go http.Handler implementations.

Layout of this package:

  • suite.go — Suite lifecycle: New, NewWithHandler, NewE2E, global headers/cookies, context bridge.
  • request.go — Request builder and every With* method; Suite's HTTP verb methods (GET, POST, …).
  • response.go — Response and every fluent assertion.
  • traverse.go — dot-path resolution used by HasField and ExpectArrayLen.
  • chaos_bridge.go — WithChaos, the only bridge from this package into testkit/chaos.
  • async.go — WaitForJSON.
  • bench.go — BenchHTTP.
  • load.go — Suite.LoadTest.
  • load_bg.go — Suite.StartBackgroundLoad.
  • sse.go, sse_wait.go — Server-Sent Events capture and waits.
  • smoke.go — RunSmokeTests.

Generic helpers (Eventually, GoldenJSON, Trace, Fake, Script, Recorder, Simulate, AssertContracts, BenchAction, xctx test contexts, xerr assertions) live in github.com/nexssp/kernel/xtest.

Subpackages (imported on demand only):

  • chaos — stochastic latency/error/panic injection.
  • rpc — JSON-RPC 2.0 test client over net.Pipe.
  • examples — runnable, self-contained demonstrations of the API.

Index

Constants

View Source
const (
	HeaderTenantID = "X-Tenant-Id"
)

Variables

This section is empty.

Functions

func BenchHTTP

func BenchHTTP(b *testing.B, s *Suite, method, path string, payload any)

BenchHTTP benchmarks the complete HTTP stack over in-memory sockets. For pure action execution without transport, use xtest.BenchAction.

func RunSmokeTests

func RunSmokeTests(t *testing.T, actions []action.AnyAction)

func WaitForJSON added in v0.3.0

func WaitForJSON[T any](
	t testing.TB,
	timeout, interval time.Duration,
	request func() (*Response, error),
	ready func(T) bool,
) T

WaitForJSON polls request until the response body decodes as T and satisfies ready, or until timeout elapses. It returns the last successfully-decoded value.

All polling and timeout semantics are delegated to kernel/xtest.EventuallyEveryE, so HTTP polling behaves exactly like every other Eventually assertion in the kernel. This function adds only the decode-then-check step.

  • nil ready accepts any decodable body.
  • timeout <= 0 performs a single synchronous attempt (matching EventuallyEveryE's contract).
  • a non-positive interval is normalized by the kernel poll loop.

On timeout the test is failed via t, and the last observed error (transport error, JSON error, or errNotReady) is included in the failure message.

func WithChaos

func WithChaos(actions []action.AnyAction, cfg chaos.Config) []action.AnyAction

WithChaos wraps provided actions with chaos fault injection.

This is the only function in package testkit that references testkit/chaos. Keeping it in its own file makes the dependency boundary explicit: any reader of the package can see at a glance that chaos is opt-in, not part of the core Suite.

Types

type FakeClock added in v0.4.0

type FakeClock struct {
	// contains filtered or unexported fields
}

FakeClock is a deterministic replacement for time.Now / time.After / time.NewTicker. Install it into a context with WithClock, and code that reads from ctx can be driven forward in tests with Advance.

This is what lets a test verify "the retry waited 200ms" without a real 200ms sleep.

func NewFakeClock added in v0.4.0

func NewFakeClock(start time.Time) *FakeClock

NewFakeClock returns a clock frozen at the given instant.

func (*FakeClock) Advance added in v0.4.0

func (c *FakeClock) Advance(d time.Duration)

Advance moves the clock forward, waking every waiter whose deadline has passed. Waiters are woken in deadline order.

func (*FakeClock) After added in v0.4.0

func (c *FakeClock) After(d time.Duration) <-chan struct{}

After returns a channel that fires when the clock has advanced past d.

func (*FakeClock) Now added in v0.4.0

func (c *FakeClock) Now() time.Time

Now returns the current fake time.

type LoadConfig

type LoadConfig struct {
	Concurrency int
	Duration    time.Duration
	Method      string
	Path        string
	Payload     any
}

type LoadResult

type LoadResult struct {
	TotalRequests int64
	Errors        int64
	ErrorRate     float64
	RPS           float64
	P50           time.Duration
	P95           time.Duration
	P99           time.Duration
}

type Request

type Request struct {
	// contains filtered or unexported fields
}

func (*Request) Do

func (r *Request) Do() *Response

Do executes the request and immediately fails the test if an error occurs.

func (*Request) DoContext

func (r *Request) DoContext(ctx context.Context) (*Response, error)

DoContext executes the HTTP request with the provided context and returns an error without calling t.Fatalf (goroutine safe).

func (*Request) DoE

func (r *Request) DoE() (*Response, error)

DoE executes the HTTP request using the request's configured context.

func (*Request) WithBearerToken

func (r *Request) WithBearerToken(token string) *Request

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) *Request

func (*Request) WithCookie

func (r *Request) WithCookie(name, value string) *Request

func (*Request) WithForm

func (r *Request) WithForm(data map[string]string) *Request

func (*Request) WithHeader

func (r *Request) WithHeader(k, v string) *Request

func (*Request) WithJSON

func (r *Request) WithJSON(v any) *Request

func (*Request) WithMultipartFile

func (r *Request) WithMultipartFile(fieldName, filename string, content []byte) *Request

func (*Request) WithQueries

func (r *Request) WithQueries(params map[string]string) *Request

func (*Request) WithQuery

func (r *Request) WithQuery(key, value string) *Request

func (*Request) WithTenant

func (r *Request) WithTenant(tenantID string) *Request

type Response

type Response struct {
	// contains filtered or unexported fields
}

func (*Response) Body

func (c *Response) Body() []byte

func (*Response) BodyString

func (c *Response) BodyString() string

func (*Response) ContainsString

func (c *Response) ContainsString(substr string) *Response

func (*Response) ExpectArrayLen

func (c *Response) ExpectArrayLen(path string, n int) *Response

func (*Response) ExpectBadRequest

func (c *Response) ExpectBadRequest() *Response

func (*Response) ExpectCreated

func (c *Response) ExpectCreated() *Response

func (*Response) ExpectErrorKind

func (c *Response) ExpectErrorKind(kind xerr.Kind, message string) *Response

func (*Response) ExpectForbidden

func (c *Response) ExpectForbidden() *Response

func (*Response) ExpectHeader

func (c *Response) ExpectHeader(key, value string) *Response

func (*Response) ExpectNotFound

func (c *Response) ExpectNotFound() *Response

func (*Response) ExpectOK

func (c *Response) ExpectOK() *Response

func (*Response) ExpectStatus

func (c *Response) ExpectStatus(code int) *Response

func (*Response) ExpectSuccess

func (c *Response) ExpectSuccess() *Response

func (*Response) ExpectUnauthorized

func (c *Response) ExpectUnauthorized() *Response

func (*Response) HasField

func (c *Response) HasField(path string, expected any) *Response

func (*Response) Header

func (c *Response) Header(k string) string

func (*Response) Into

func (c *Response) Into(v any) *Response

func (*Response) Status

func (c *Response) Status() int

type SSEEvent

type SSEEvent struct {
	Event string
	Data  string
}

type StreamCapture

type StreamCapture struct {
	// contains filtered or unexported fields
}

func (*StreamCapture) Close

func (sc *StreamCapture) Close()

func (*StreamCapture) Endpoint added in v0.2.0

func (sc *StreamCapture) Endpoint(t testing.TB, timeout time.Duration) string

Endpoint conveniently extracts an MCP SSE endpoint event.

func (*StreamCapture) WaitFor

func (sc *StreamCapture) WaitFor(t testing.TB, eventName string, timeout time.Duration) SSEEvent

func (*StreamCapture) WaitForData added in v0.2.0

func (sc *StreamCapture) WaitForData(t testing.TB, substr string, timeout time.Duration) SSEEvent

func (*StreamCapture) WaitForSSE added in v0.3.0

func (sc *StreamCapture) WaitForSSE(t testing.TB, timeout time.Duration, match func(SSEEvent) bool) SSEEvent

WaitForSSE waits for the first buffered SSE event accepted by match. Events that do not match are discarded, just like StreamCapture.WaitFor and WaitForData. A nil match predicate is rejected to avoid an accidental match-all wait; use WaitFor with an empty event name when matching any event.

func (*StreamCapture) WaitForSSEData added in v0.3.0

func (sc *StreamCapture) WaitForSSEData(t testing.TB, substr string, timeout time.Duration) SSEEvent

WaitForSSEData waits for an SSE event whose data contains substr. It is the predicate equivalent of StreamCapture.WaitForData and is useful when a test needs the event name as well as a data substring.

type Suite

type Suite struct {
	T      testing.TB
	Server *httptest.Server
	// contains filtered or unexported fields
}

Suite wraps an in-memory or live HTTP server with fluent test assertions.

func New

func New(t testing.TB, providers ...any) *Suite

New flattens nexssp actions and mounts them onto an in-memory transport.

func NewE2E

func NewE2E(t testing.TB, baseURL string) *Suite

NewE2E initializes the suite against a live, external URL.

func NewWithHandler

func NewWithHandler(t testing.TB, h http.Handler) *Suite

NewWithHandler initializes a test suite against ANY standard Go http.Handler.

func (*Suite) DELETE

func (s *Suite) DELETE(path string, body ...any) *Request

func (*Suite) GET

func (s *Suite) GET(path string, body ...any) *Request

func (*Suite) ListenSSE

func (s *Suite) ListenSSE(path string) *StreamCapture

ListenSSE connects to an SSE endpoint using GET.

func (*Suite) ListenSSEWithRequest added in v0.2.0

func (s *Suite) ListenSSEWithRequest(t testing.TB, req *http.Request) *StreamCapture

ListenSSEWithRequest connects to an SSE endpoint using a custom HTTP request. This supports POST + SSE patterns such as MCP Streamable HTTP and A2A.

func (*Suite) LoadTest

func (s *Suite) LoadTest(t *testing.T, cfg LoadConfig) LoadResult

LoadTest executes in-process stress tests, properly propagating cancellation to in-flight requests.

func (*Suite) PATCH

func (s *Suite) PATCH(path string, body ...any) *Request

func (*Suite) POST

func (s *Suite) POST(path string, body ...any) *Request

func (*Suite) PUT

func (s *Suite) PUT(path string, body ...any) *Request

func (*Suite) Request

func (s *Suite) Request(method, path string) *Request

func (*Suite) ResetHeaders

func (s *Suite) ResetHeaders() *Suite

func (*Suite) StartBackgroundLoad

func (s *Suite) StartBackgroundLoad(cfg LoadConfig) func()

StartBackgroundLoad generates background load, correctly checking for URL/request errors.

func (*Suite) WithCookie

func (s *Suite) WithCookie(name, value string) *Suite

func (*Suite) WithGlobalBearerToken

func (s *Suite) WithGlobalBearerToken(token string) *Suite

func (*Suite) WithGlobalHeader

func (s *Suite) WithGlobalHeader(key, value string) *Suite

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL