test: verify model actually reaches provider in WithModel test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mingmxren 2026-03-06 13:04:53 +08:00
parent 1b96f79577
commit d48044e3fb

View file

@ -12,6 +12,7 @@ import (
// MockLLMProvider is a test implementation of LLMProvider // MockLLMProvider is a test implementation of LLMProvider
type MockLLMProvider struct { type MockLLMProvider struct {
lastOptions map[string]any lastOptions map[string]any
lastModel string
} }
func (m *MockLLMProvider) Chat( func (m *MockLLMProvider) Chat(
@ -22,6 +23,7 @@ func (m *MockLLMProvider) Chat(
options map[string]any, options map[string]any,
) (*providers.LLMResponse, error) { ) (*providers.LLMResponse, error) {
m.lastOptions = options m.lastOptions = options
m.lastModel = model
// Find the last user message to generate a response // Find the last user message to generate a response
for i := len(messages) - 1; i >= 0; i-- { for i := len(messages) - 1; i >= 0; i-- {
if messages[i].Role == "user" { if messages[i].Role == "user" {
@ -381,6 +383,9 @@ func TestSubagentTool_Execute_WithModel(t *testing.T) {
if result.IsError { if result.IsError {
t.Errorf("Expected success, got error: %s", result.ForLLM) t.Errorf("Expected success, got error: %s", result.ForLLM)
} }
if provider.lastModel != "custom-model" {
t.Errorf("expected model 'custom-model', got %q", provider.lastModel)
}
} }
func TestSubagentTool_Execute_WithInvalidModel(t *testing.T) { func TestSubagentTool_Execute_WithInvalidModel(t *testing.T) {