Documentation
¶
Overview ¶
Package testutil provides helpers for unit and integration tests.
Index ¶
- func AssertJSONEqual(t *testing.T, expected, actual string)
- func LoadTestAudio(t *testing.T, filename string) []byte
- func NewMockLLMBackend(name string, response *llm.LLMResponse) llm.LLMBackend
- func NewTestLogger() *logrus.Logger
- func RepoRoot(t *testing.T) string
- type MockLLMBackend
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertJSONEqual ¶
AssertJSONEqual unmarshals and compares two JSON strings.
func LoadTestAudio ¶
LoadTestAudio loads an audio sample from the repository's test data directory.
func NewMockLLMBackend ¶
func NewMockLLMBackend(name string, response *llm.LLMResponse) llm.LLMBackend
NewMockLLMBackend creates a mock LLM backend with a fixed response.
func NewTestLogger ¶
NewTestLogger creates a logger suitable for tests.
Types ¶
type MockLLMBackend ¶
type MockLLMBackend struct {
Name string
Response *llm.LLMResponse
ProcessErr error
HealthErr error
}
MockLLMBackend is a configurable in-memory LLM backend for unit tests.
func (*MockLLMBackend) GetCapabilities ¶
func (b *MockLLMBackend) GetCapabilities() llm.Capabilities
func (*MockLLMBackend) GetName ¶
func (b *MockLLMBackend) GetName() string
func (*MockLLMBackend) HealthCheck ¶
func (b *MockLLMBackend) HealthCheck(ctx context.Context) error
func (*MockLLMBackend) Process ¶
func (b *MockLLMBackend) Process(ctx context.Context, req *llm.LLMRequest) (*llm.LLMResponse, error)
type TestServer ¶
type TestServer struct {
Server *httptest.Server
Client *http.Client
Config *config.Config
Mux *http.ServeMux
}
TestServer is a lightweight integration test harness based on httptest.Server.
It intentionally does not depend on application packages to avoid import cycles in unit tests. Tests can register handlers on Mux and issue requests via DoRequest.
func NewTestServer ¶
func NewTestServer(t *testing.T) *TestServer
NewTestServer creates a new TestServer backed by an http.ServeMux.
func (*TestServer) Cleanup ¶
func (ts *TestServer) Cleanup()
Cleanup closes the underlying server. It is safe to call multiple times.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package integrationtest provides Lingualink-specific integration test helpers.
|
Package integrationtest provides Lingualink-specific integration test helpers. |