fix: update tests to match upstream API changes

Fix web_test.go and config_test.go to use current function signatures
after merging upstream changes (WebSearchToolOptions, BraveConfig).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ex-takashima
2026-02-14 11:32:42 +09:00
parent ac79a23e0a
commit 6463796fa1
2 changed files with 13 additions and 21 deletions

View File

@@ -136,11 +136,14 @@ func TestDefaultConfig_WebTools(t *testing.T) {
cfg := DefaultConfig() cfg := DefaultConfig()
// Verify web tools defaults // Verify web tools defaults
if cfg.Tools.Web.Search.MaxResults != 5 { if cfg.Tools.Web.Brave.MaxResults != 5 {
t.Error("Expected MaxResults 5, got ", cfg.Tools.Web.Search.MaxResults) t.Error("Expected Brave MaxResults 5, got ", cfg.Tools.Web.Brave.MaxResults)
} }
if cfg.Tools.Web.Search.APIKey != "" { if cfg.Tools.Web.Brave.APIKey != "" {
t.Error("Search API key should be empty by default") t.Error("Brave API key should be empty by default")
}
if cfg.Tools.Web.DuckDuckGo.MaxResults != 5 {
t.Error("Expected DuckDuckGo MaxResults 5, got ", cfg.Tools.Web.DuckDuckGo.MaxResults)
} }
} }

View File

@@ -173,30 +173,19 @@ func TestWebTool_WebFetch_Truncation(t *testing.T) {
} }
} }
// TestWebTool_WebSearch_NoApiKey verifies error handling when API key is missing // TestWebTool_WebSearch_NoApiKey verifies that nil is returned when no provider is configured
func TestWebTool_WebSearch_NoApiKey(t *testing.T) { func TestWebTool_WebSearch_NoApiKey(t *testing.T) {
tool := NewWebSearchTool("", 5) tool := NewWebSearchTool(WebSearchToolOptions{BraveAPIKey: "", BraveMaxResults: 5})
ctx := context.Background()
args := map[string]interface{}{
"query": "test",
}
result := tool.Execute(ctx, args) // Should return nil when no provider is enabled
if tool != nil {
// Should return error result t.Errorf("Expected nil when no search provider is configured")
if !result.IsError {
t.Errorf("Expected error when API key is missing")
}
// Should mention missing API key
if !strings.Contains(result.ForLLM, "BRAVE_API_KEY") && !strings.Contains(result.ForUser, "BRAVE_API_KEY") {
t.Errorf("Expected API key error message, got ForLLM: %s", result.ForLLM)
} }
} }
// TestWebTool_WebSearch_MissingQuery verifies error handling for missing query // TestWebTool_WebSearch_MissingQuery verifies error handling for missing query
func TestWebTool_WebSearch_MissingQuery(t *testing.T) { func TestWebTool_WebSearch_MissingQuery(t *testing.T) {
tool := NewWebSearchTool("test-key", 5) tool := NewWebSearchTool(WebSearchToolOptions{BraveAPIKey: "test-key", BraveMaxResults: 5, BraveEnabled: true})
ctx := context.Background() ctx := context.Background()
args := map[string]interface{}{} args := map[string]interface{}{}