- Add integration tests for Ollama provider (17 tests against real API) - Add unit tests for baseline, correlation, patterns, memory, knowledge, cost packages - Add context formatter and builder tests - Add factory tests for provider initialization - Add Makefile targets: test-integration, test-all - Clean up test theatre (removed struct field tests) Integration tests require Ollama at OLLAMA_URL (default: 192.168.0.124:11434) Run with: make test-integration
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package providers
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// Anthropic tests are limited because the client hardcodes API URLs.
|
|
// These tests verify context handling and basic construction.
|
|
|
|
func TestAnthropicClient_Name(t *testing.T) {
|
|
client := NewAnthropicClient("test-key", "claude-3-5-sonnet")
|
|
if client.Name() != "anthropic" {
|
|
t.Errorf("Expected 'anthropic', got '%s'", client.Name())
|
|
}
|
|
}
|
|
|
|
func TestAnthropicClient_Chat_ContextCanceled(t *testing.T) {
|
|
client := NewAnthropicClient("test-key", "claude-3-5-sonnet")
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
cancel() // Cancel immediately
|
|
|
|
_, err := client.Chat(ctx, ChatRequest{
|
|
Messages: []Message{{Role: "user", Content: "Hello"}},
|
|
})
|
|
|
|
if err == nil {
|
|
t.Error("Expected error for canceled context")
|
|
}
|
|
}
|
|
|
|
func TestAnthropicClient_Chat_Timeout(t *testing.T) {
|
|
client := NewAnthropicClient("test-key", "claude-3-5-sonnet")
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Millisecond)
|
|
defer cancel()
|
|
|
|
_, err := client.Chat(ctx, ChatRequest{
|
|
Messages: []Message{{Role: "user", Content: "Hello"}},
|
|
})
|
|
|
|
if err == nil {
|
|
t.Error("Expected timeout error")
|
|
}
|
|
}
|