test: añadir tests para claude-code provider y router
27 tests nuevos cubriendo las funciones del provider claude-code: - buildClaudeArgs: minimal, all options, disable_tools, disallowed_tools - flattenMessages: empty, multi-role, skips system messages - parseClaudeOutput: success, error response, process failed (con/sin stderr), fallback a plain text, content blocks, exec error con stdout parcial - filterEnv: single key, multiple keys, no match, prefix safety - Route: claude-code, claude-code/custom, claude-*, gpt-*, ollama/*, default - ModelName: ollama prefix strip, passthrough Todos pasan con 'go test -tags goolm ./shell/llm/ ./pkg/llm/'.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package llm
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRoute(t *testing.T) {
|
||||
tests := []struct {
|
||||
model string
|
||||
want ProviderID
|
||||
}{
|
||||
{"claude-code", ProviderClaudeCode},
|
||||
{"claude-code/custom", ProviderClaudeCode},
|
||||
{"claude-sonnet-4-5-20250929", ProviderAnthropic},
|
||||
{"claude-opus-4", ProviderAnthropic},
|
||||
{"gpt-4o", ProviderOpenAI},
|
||||
{"o1-preview", ProviderOpenAI},
|
||||
{"o3-mini", ProviderOpenAI},
|
||||
{"ollama/mistral", ProviderOllama},
|
||||
{"unknown-model", ProviderOpenAI}, // default
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.model, func(t *testing.T) {
|
||||
got := Route(tt.model)
|
||||
if got != tt.want {
|
||||
t.Errorf("Route(%q) = %q, want %q", tt.model, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelName(t *testing.T) {
|
||||
tests := []struct {
|
||||
input, want string
|
||||
}{
|
||||
{"ollama/mistral", "mistral"},
|
||||
{"gpt-4o", "gpt-4o"},
|
||||
{"claude-sonnet-4-5-20250929", "claude-sonnet-4-5-20250929"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.input, func(t *testing.T) {
|
||||
got := ModelName(tt.input)
|
||||
if got != tt.want {
|
||||
t.Errorf("ModelName(%q) = %q, want %q", tt.input, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user