Documentation
¶
Overview ¶
Package testing provides test utilities for NestGo applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockProvider ¶
MockProvider creates a mock provider for testing.
Types ¶
type TestApp ¶
TestApp provides a test harness for NestGo applications.
func NewTestApp ¶
NewTestApp creates a new test application.
func (*TestApp) OverrideProvider ¶
OverrideProvider replaces a provider in the DI container (for mocking).
type TestRequest ¶
type TestRequest struct {
// contains filtered or unexported fields
}
TestRequest builds and sends test HTTP requests.
func POST ¶
func POST(baseURL, path string, body any) *TestRequest
POST creates a POST test request.
func (*TestRequest) Send ¶
func (r *TestRequest) Send() (*TestResponse, error)
Send sends the request and returns the response.
func (*TestRequest) WithAuth ¶
func (r *TestRequest) WithAuth(token string) *TestRequest
WithAuth adds a bearer token.
func (*TestRequest) WithHeader ¶
func (r *TestRequest) WithHeader(key, value string) *TestRequest
WithHeader adds a header.
type TestResponse ¶
TestResponse wraps an HTTP response with convenience methods.
func (*TestResponse) BodyString ¶
func (r *TestResponse) BodyString() string
BodyString returns the response body as a string.
func (*TestResponse) IsCreated ¶
func (r *TestResponse) IsCreated() bool
IsCreated returns true if status is 201.
func (*TestResponse) IsNotFound ¶
func (r *TestResponse) IsNotFound() bool
IsNotFound returns true if status is 404.
func (*TestResponse) JSON ¶
func (r *TestResponse) JSON(v any) error
JSON decodes the response body as JSON.