Documentation
¶
Overview ¶
Package blwatest provides test helpers for blwa applications.
It constructs the identical DI graph as blwa.NewApp but uses fxtest.App which fails the test immediately on DI errors.
Example:
blwatest.SetBaseEnv(t, 18081) app := blwatest.New[TestEnv](t, routing, blwa.WithAWSClient(...)) app.RequireStart() t.Cleanup(app.RequireStop)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallHandler ¶ added in v0.7.2
func CallHandler(handler bhttp.HandlerFunc, req *http.Request) *httptest.ResponseRecorder
CallHandler invokes a bhttp.HandlerFunc with a buffered response writer and returns the recorded response. It handles the boilerplate of wrapping httptest.ResponseRecorder in a bhttp.ResponseWriter and flushing the buffer afterward.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env provides a chainable builder for setting blwa.BaseEnvironment env vars via t.Setenv. Create one with SetBaseEnv.
func SetBaseEnv ¶
SetBaseEnv sets all blwa.BaseEnvironment env vars to sensible test defaults. Port is required because each test must use a unique port to avoid collisions.
Defaults:
- BW_SERVICE_NAME: "test"
- AWS_LWA_READINESS_CHECK_PATH: "/health"
- AWS_REGION: "us-east-1"
- BW_PRIMARY_REGION: "eu-west-1"
- BW_LAMBDA_TIMEOUT: "30s"
- AWS_LWA_ERROR_STATUS_CODES: "500-599"
- OTEL_SDK_DISABLED: "true"
- AWS_ACCESS_KEY_ID: "test"
- AWS_SECRET_ACCESS_KEY: "test"
Use the returned Env to override individual values:
blwatest.SetBaseEnv(t, 18085).AWSRegion("eu-west-1").PrimaryRegion("eu-central-1")
func (*Env) LambdaTimeout ¶
LambdaTimeout overrides BW_LAMBDA_TIMEOUT.
func (*Env) PrimaryRegion ¶
PrimaryRegion overrides BW_PRIMARY_REGION.
func (*Env) ReadinessCheckPath ¶
ReadinessCheckPath overrides AWS_LWA_READINESS_CHECK_PATH.
func (*Env) ServiceName ¶
ServiceName overrides BW_SERVICE_NAME.