Documentation
¶
Overview ¶
Package testutils provides common utilities for testing across the project.
Index ¶
- func AssertErrorContains(t *testing.T, err error, expected string)
- func CreateMockJSONResponse(t *testing.T, statusCode int, body interface{}) *http.Response
- func CreateTempFile(t *testing.T, content string) string
- func GetProjectRoot() (string, error)
- func LoadTestFile(t *testing.T, relativePath string) []byte
- func RunTestCases(t *testing.T, testCases []TestCase)
- func SetupMockServer(t *testing.T, configs []MockServerConfig) (*httptest.Server, string)
- func SkipIfNotIntegration(t *testing.T)
- func SkipIfShort(t *testing.T)
- type MockServerConfig
- type TestCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrorContains ¶
AssertErrorContains checks if the error message contains the expected text.
func CreateMockJSONResponse ¶
CreateMockJSONResponse creates a mock HTTP response with JSON content.
func CreateTempFile ¶
CreateTempFile creates a temporary file with the given content and returns its path. The caller is responsible for cleaning up the file.
func GetProjectRoot ¶
GetProjectRoot returns the absolute path to the project root.
func LoadTestFile ¶
LoadTestFile reads and returns the content of a test file.
func RunTestCases ¶
RunTestCases runs a set of test cases with proper setup and teardown.
func SetupMockServer ¶
SetupMockServer creates a test HTTP server with the given configuration. Returns the server instance and its base URL.
func SkipIfNotIntegration ¶
SkipIfNotIntegration skips the test if the -integration flag is not set.
func SkipIfShort ¶
SkipIfShort skips the test if the -short flag is set.