Documentation
¶
Index ¶
- func AssertEqual(t *testing.T, expected, actual any)
- func AssertError(t *testing.T, err error)
- func AssertErrorContains(t *testing.T, err error, expected string)
- func AssertFalse(t *testing.T, condition bool)
- func AssertNil(t *testing.T, value any)
- func AssertNoError(t *testing.T, err error)
- func AssertNotNil(t *testing.T, value any)
- func AssertTrue(t *testing.T, condition bool)
- func Contains(s, substr string) bool
- func CreateTestCache() *sync.Map
- func CreateTestContext() context.Context
- func CreateTestLogger() *logrus.Logger
- func ExtractPackageVersions(t *testing.T, result any) []packageversions.PackageVersion
- func WithEnv(t *testing.T, key, value string) func()
- func WithEnvUnset(t *testing.T, key string) func()
- type MockCache
- type MockHTTPClient
- type MockHTTPResponse
- type MockReadCloser
- type MockTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
AssertEqual fails the test if expected != actual
func AssertError ¶
AssertError fails the test if err is nil
func AssertErrorContains ¶
AssertErrorContains fails the test if err is nil or doesn't contain the expected message
func AssertFalse ¶ added in v0.21.1
AssertFalse fails the test if condition is true
func AssertNil ¶ added in v0.33.2
AssertNil asserts that a value is nil AssertNil asserts that a value is nil AssertNil asserts that a value is nil
func AssertNoError ¶
AssertNoError fails the test if err is not nil
func AssertNotNil ¶
AssertNotNil fails the test if value is nil
func AssertTrue ¶ added in v0.21.1
AssertTrue fails the test if condition is false
func CreateTestCache ¶
CreateTestCache creates a cache suitable for testing
func CreateTestContext ¶
CreateTestContext creates a context suitable for testing
func CreateTestLogger ¶
CreateTestLogger creates a logger suitable for testing
func ExtractPackageVersions ¶ added in v0.28.0
func ExtractPackageVersions(t *testing.T, result any) []packageversions.PackageVersion
ExtractPackageVersions extracts PackageVersion structs from a tool result
func WithEnv ¶ added in v0.50.5
WithEnv sets an environment variable for the duration of a test and returns a cleanup function. Usage:
cleanup := testutils.WithEnv(t, "ENABLE_ADDITIONAL_TOOLS", "tool-name") defer cleanup()
func WithEnvUnset ¶ added in v0.50.5
WithEnvUnset unsets an environment variable for the duration of a test and returns a cleanup function. Usage:
defer testutils.WithEnvUnset(t, "ENABLE_ADDITIONAL_TOOLS")()
Types ¶
type MockCache ¶
type MockCache struct {
// contains filtered or unexported fields
}
MockCache provides a controllable cache for testing
type MockHTTPClient ¶
type MockHTTPClient struct {
// contains filtered or unexported fields
}
MockHTTPClient for testing HTTP-based tools
func NewMockHTTPClient ¶
func NewMockHTTPClient() *MockHTTPClient
NewMockHTTPClient creates a new mock HTTP client
func (*MockHTTPClient) GetWithContext ¶ added in v0.56.0
GetWithContext simulates an HTTP GET request with context support (implements shadcnui.HTTPClient interface)
func (*MockHTTPClient) WithError ¶
func (m *MockHTTPClient) WithError(err error) *MockHTTPClient
WithError configures the mock to return an error
func (*MockHTTPClient) WithResponse ¶
func (m *MockHTTPClient) WithResponse(url string, statusCode int, body string) *MockHTTPClient
WithResponse configures a response for a specific URL
type MockHTTPResponse ¶
MockHTTPResponse simulates an HTTP response
type MockReadCloser ¶
type MockReadCloser struct {
// contains filtered or unexported fields
}
MockReadCloser implements io.ReadCloser for mock responses
type MockTool ¶
type MockTool struct {
// contains filtered or unexported fields
}
MockTool implements the Tool interface for testing
func (*MockTool) Definition ¶
Definition returns the tool's definition for MCP registration
func (*MockTool) Execute ¶
func (m *MockTool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)
Execute executes the mock tool
func (*MockTool) WithResult ¶
func (m *MockTool) WithResult(result *mcp.CallToolResult) *MockTool
WithResult configures the mock to return a specific result