testkit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const EnvTestDBDSN = "TEST_DB_DSN"

Variables

This section is empty.

Functions

func AssertError

func AssertError(t *testing.T, resp *http.Response, wantCode wserr.Code) wserr.Error

func AssertHTTPStatus

func AssertHTTPStatus(t *testing.T, got, want int, body []byte)

func DecodeJSON

func DecodeJSON[T any](t *testing.T, b []byte) T

func OpenTestDB

func OpenTestDB(t *testing.T) *sql.DB

func ReadBody

func ReadBody(t *testing.T, r io.Reader) []byte

func WithTimeout

func WithTimeout(t *testing.T, d time.Duration) context.Context

Types

type HTTPServerOptions

type HTTPServerOptions struct {
	Logger            *wslog.Logger
	BodyLimit         int64
	MetricsRouteLabel string // optional
}

type HTTPTestServer

type HTTPTestServer struct {
	Server *httptest.Server
	Client *http.Client
}

func NewServer

func NewServer(h http.Handler, opts HTTPServerOptions) *HTTPTestServer

NewServer spins up an httptest server with a standard middleware chain. Keep it router-agnostic: caller provides the final handler.

func (*HTTPTestServer) Close

func (s *HTTPTestServer) Close()

Jump to

Keyboard shortcuts

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