Documentation
¶
Overview ¶
Package testutil provides common test utilities and helpers
Index ¶
- func AssertJSONResponse(t *testing.T, w *httptest.ResponseRecorder, expected any)
- func ContextWithTimeout(t *testing.T, timeout time.Duration) (context.Context, context.CancelFunc)
- func GenerateLargePayload(sizeBytes int) []byte
- func RandomString(length int) string
- func WaitForCondition(t *testing.T, timeout time.Duration, check func() bool, message string)
- type Agent
- type Context
- type HTTPClient
- type MockClock
- type Model
- type TestConfig
- type TestDatabase
- type TestFixtures
- type TestMetrics
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertJSONResponse ¶
func AssertJSONResponse(t *testing.T, w *httptest.ResponseRecorder, expected any)
AssertJSONResponse asserts JSON response matches expected structure
func ContextWithTimeout ¶
ContextWithTimeout creates a context with timeout and cleanup
func GenerateLargePayload ¶
GenerateLargePayload generates a large payload for testing
func RandomString ¶
RandomString generates a random string of given length
Types ¶
type Agent ¶
type Agent struct { ID string `json:"id"` TenantID string `json:"tenant_id"` Name string `json:"name"` Description string `json:"description"` Config map[string]any `json:"config"` }
Agent represents a test agent
type Context ¶
type Context struct { ID string `json:"id"` AgentID string `json:"agent_id"` ModelID string `json:"model_id"` MaxTokens int `json:"max_tokens"` Metadata map[string]any `json:"metadata"` CreatedAt time.Time `json:"created_at"` }
Context represents a test context
type HTTPClient ¶
HTTPClient provides a test HTTP client
func NewHTTPClient ¶
func NewHTTPClient(config *TestConfig) *HTTPClient
NewHTTPClient creates a new test HTTP client
type MockClock ¶
MockClock provides a mock clock for testing
type Model ¶
type Model struct { ID string `json:"id"` TenantID string `json:"tenant_id"` Name string `json:"name"` Provider string `json:"provider"` ModelType string `json:"model_type"` }
Model represents a test model
type TestConfig ¶
type TestConfig struct { DatabaseDSN string RedisAddr string APIBaseURL string TestTenantID string TestAuthToken string }
TestConfig holds test configuration
func LoadTestConfig ¶
func LoadTestConfig() *TestConfig
LoadTestConfig loads test configuration from environment
type TestDatabase ¶
TestDatabase provides test database utilities
func NewTestDatabase ¶
func NewTestDatabase(t *testing.T, dsn string) *TestDatabase
NewTestDatabase creates a new test database connection
type TestFixtures ¶
TestFixtures provides test data fixtures
func LoadFixtures ¶
func LoadFixtures(tenantID string) *TestFixtures
LoadFixtures loads test fixtures
type TestMetrics ¶
type TestMetrics struct { Counters map[string]int64 Gauges map[string]float64 // contains filtered or unexported fields }
TestMetrics provides test metrics collection
func NewTestMetrics ¶
func NewTestMetrics() *TestMetrics
NewTestMetrics creates a new test metrics collector
func (*TestMetrics) GetCounter ¶
func (tm *TestMetrics) GetCounter(name string) int64
GetCounter gets a counter value
func (*TestMetrics) GetGauge ¶
func (tm *TestMetrics) GetGauge(name string) float64
GetGauge gets a gauge value
func (*TestMetrics) IncrCounter ¶
func (tm *TestMetrics) IncrCounter(name string, value int64)
IncrCounter increments a counter
func (*TestMetrics) SetGauge ¶
func (tm *TestMetrics) SetGauge(name string, value float64)
SetGauge sets a gauge value
type TestServer ¶
TestServer provides a test Gin server
func (*TestServer) AddAuthMiddleware ¶
func (ts *TestServer) AddAuthMiddleware()
AddAuthMiddleware adds test authentication middleware
func (*TestServer) ServeHTTP ¶
func (ts *TestServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler