Documentation
¶
Overview ¶
Package testutil provides common test utilities and helpers for PromptPipe tests.
Index ¶
- func AssertHTTPStatus(t TestingT, expected, actual int, context string)
- func AssertJSONResponse(t TestingT, rr *httptest.ResponseRecorder, expectedStatus string) map[string]interface{}
- func AssertPromptEquals(t TestingT, expected, actual models.Prompt, context string)
- func AssertResponseCount(t TestingT, store store.Store, expected int, context string)
- func CreateHTTPRequest(t TestingT, method, url string, body interface{}) *http.Request
- func CreateJSONRequest(t TestingT, method, url, jsonBody string) *http.Request
- func MustMarshalJSON(t TestingT, v interface{}) []byte
- func MustUnmarshalJSON(t TestingT, data []byte, target interface{})
- func NewTestServer() *api.Server
- func SeedTestData(t TestingT, store store.Store)
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertHTTPStatus ¶
AssertHTTPStatus checks the HTTP status code and fails the test if it doesn't match.
func AssertJSONResponse ¶
func AssertJSONResponse(t TestingT, rr *httptest.ResponseRecorder, expectedStatus string) map[string]interface{}
AssertJSONResponse decodes JSON response and validates the status field.
func AssertPromptEquals ¶
AssertPromptEquals compares two Prompt structs for equality in tests.
func AssertResponseCount ¶
AssertResponseCount validates the number of responses in store matches expected.
func CreateHTTPRequest ¶
CreateHTTPRequest creates an HTTP request with optional JSON body for testing.
func CreateJSONRequest ¶
CreateJSONRequest creates an HTTP request with a JSON string body for testing. This is a convenience wrapper around CreateHTTPRequest for JSON string bodies.
func MustMarshalJSON ¶
MustMarshalJSON marshals an object to JSON and fails test on error.
func MustUnmarshalJSON ¶
MustUnmarshalJSON unmarshals JSON data into target and fails test on error.
func NewTestServer ¶
NewTestServer creates a test API server with in-memory dependencies. This centralizes the test server creation logic used across multiple test files.
func SeedTestData ¶
SeedTestData adds sample data to the store for testing.
Types ¶
type TestingT ¶
type TestingT interface { Helper() Error(args ...interface{}) Errorf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) }
TestingT defines the interface that testing types must implement. This allows both *testing.T and mock implementations to be used.