Documentation
¶
Overview ¶
Package testutil holds shared test helpers — fixture builders, fake HTTP recorders, and time-freezing utilities — used across unit, attack, compliance, and integration test suites.
Index ¶
- func AssertStatus(t *testing.T, resp *http.Response, expected int)
- func AuthRequest(t *testing.T, client *http.Client, method, url, accessToken string, ...) *http.Response
- func ContainerRuntimeAvailable() bool
- func ContainerRuntimeHost() string
- func DecodeJSON(t *testing.T, resp *http.Response) map[string]interface{}
- func ExtractCookies(resp *http.Response) map[string]*http.Cookie
- func LoginUser(t *testing.T, client *http.Client, baseURL, email, password string) (map[string]interface{}, []*http.Cookie)
- func NoRedirectClient() *http.Client
- func RefreshTokens(t *testing.T, client *http.Client, baseURL string, cookies []*http.Cookie) (map[string]interface{}, []*http.Cookie)
- func RegisterUser(t *testing.T, client *http.Client, baseURL, email, password string) map[string]interface{}
- func RequireContainerRuntime(t *testing.T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStatus ¶
AssertStatus checks the HTTP status code.
func AuthRequest ¶
func AuthRequest(t *testing.T, client *http.Client, method, url, accessToken string, body interface{}) *http.Response
AuthRequest makes an authenticated request with a Bearer token.
func ContainerRuntimeAvailable ¶ added in v1.0.3
func ContainerRuntimeAvailable() bool
ContainerRuntimeAvailable reports whether a container daemon answered.
It never blocks longer than the detection budget, and the answer is computed once per test binary.
func ContainerRuntimeHost ¶ added in v1.0.3
func ContainerRuntimeHost() string
ContainerRuntimeHost returns the DOCKER_HOST of the daemon that answered, or "" when none did. DOCKER_HOST is exported to the process as a side effect of the first call, so testcontainers picks up the same daemon this probed.
func DecodeJSON ¶
DecodeJSON reads and decodes JSON from an http.Response body. Closes the body.
func ExtractCookies ¶
ExtractCookies returns a map of cookie name -> cookie from the response.
func LoginUser ¶
func LoginUser(t *testing.T, client *http.Client, baseURL, email, password string) (map[string]interface{}, []*http.Cookie)
LoginUser logs in and returns the response + cookies.
func NoRedirectClient ¶
NoRedirectClient returns an HTTP client that doesn't follow redirects.
func RefreshTokens ¶
func RefreshTokens(t *testing.T, client *http.Client, baseURL string, cookies []*http.Cookie) (map[string]interface{}, []*http.Cookie)
RefreshTokens refreshes using cookies, returns new response + cookies.
func RegisterUser ¶
func RegisterUser(t *testing.T, client *http.Client, baseURL, email, password string) map[string]interface{}
RegisterUser registers a test user and returns the response.
func RequireContainerRuntime ¶ added in v1.0.3
RequireContainerRuntime points DOCKER_HOST at a container daemon that answers, or skips the test.
Skipping rather than failing keeps a runtime-free machine distinguishable from a broken repository; the canonical coverage run refuses to start without a runtime (cov_require_runtime), so nothing is silently skipped there. The skip message carries the full probe trace, because "no container runtime" and "the runtime you have is wedged" need different fixes and an operator cannot tell them apart from the outcome alone.
Types ¶
This section is empty.