Akron | b1c71e6 | 2025-06-12 16:08:54 +0200 | [diff] [blame^] | 1 | package tools |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/korap/korap-mcp/service" |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | ) |
| 9 | |
| 10 | func TestSearchTool_Name(t *testing.T) { |
| 11 | client := &service.Client{} |
| 12 | tool := NewSearchTool(client) |
| 13 | |
| 14 | assert.Equal(t, "korap_search", tool.Name()) |
| 15 | } |
| 16 | |
| 17 | func TestSearchTool_Description(t *testing.T) { |
| 18 | client := &service.Client{} |
| 19 | tool := NewSearchTool(client) |
| 20 | |
| 21 | expected := "Search for words or phrases in KorAP corpora using various query languages" |
| 22 | assert.Equal(t, expected, tool.Description()) |
| 23 | } |
| 24 | |
| 25 | func TestSearchTool_InputSchema(t *testing.T) { |
| 26 | client := &service.Client{} |
| 27 | tool := NewSearchTool(client) |
| 28 | |
| 29 | schema := tool.InputSchema() |
| 30 | |
| 31 | // Verify it's an object type |
| 32 | assert.Equal(t, "object", schema["type"]) |
| 33 | |
| 34 | // Verify properties exist |
| 35 | properties, ok := schema["properties"].(map[string]interface{}) |
| 36 | assert.True(t, ok) |
| 37 | assert.Contains(t, properties, "query") |
| 38 | assert.Contains(t, properties, "query_language") |
| 39 | assert.Contains(t, properties, "corpus") |
| 40 | assert.Contains(t, properties, "count") |
| 41 | // Note: offset and context will be added in future iterations |
| 42 | |
| 43 | // Verify required fields |
| 44 | required, ok := schema["required"].([]string) |
| 45 | assert.True(t, ok) |
| 46 | assert.Contains(t, required, "query") |
| 47 | } |
| 48 | |
| 49 | func TestNewSearchTool(t *testing.T) { |
| 50 | client := &service.Client{} |
| 51 | tool := NewSearchTool(client) |
| 52 | |
| 53 | assert.NotNil(t, tool) |
| 54 | assert.Equal(t, client, tool.client) |
| 55 | } |
| 56 | |
| 57 | // TestSearchTool_Execute will be implemented once the Execute method is fixed |
| 58 | func TestSearchTool_Execute_WillBeImplemented(t *testing.T) { |
| 59 | t.Skip("Execute method needs to be fixed first") |
| 60 | |
| 61 | // This test will be implemented once we fix the linter errors |
| 62 | // in the Execute method |
| 63 | } |