From 94923948e1a1525988bf13025a10cc9226652684 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Tue, 8 Apr 2025 19:15:23 +0200 Subject: structure tools the same - add some tests - fix some tests - change how we handle permissions --- internal/llm/tools/sourcegraph_test.go | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'internal/llm/tools/sourcegraph_test.go') diff --git a/internal/llm/tools/sourcegraph_test.go b/internal/llm/tools/sourcegraph_test.go index 5657ccd7e..89829aefc 100644 --- a/internal/llm/tools/sourcegraph_test.go +++ b/internal/llm/tools/sourcegraph_test.go @@ -5,7 +5,6 @@ import ( "encoding/json" "testing" - "github.com/kujtimiihoxha/termai/internal/permission" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -23,13 +22,6 @@ func TestSourcegraphTool_Info(t *testing.T) { } func TestSourcegraphTool_Run(t *testing.T) { - // Setup a mock permission handler that always allows - origPermission := permission.Default - defer func() { - permission.Default = origPermission - }() - permission.Default = newMockPermissionService(true) - t.Run("handles missing query parameter", func(t *testing.T) { tool := NewSourcegraphTool() params := SourcegraphParams{ @@ -61,27 +53,6 @@ func TestSourcegraphTool_Run(t *testing.T) { assert.Contains(t, response.Content, "Failed to parse sourcegraph parameters") }) - t.Run("handles permission denied", func(t *testing.T) { - permission.Default = newMockPermissionService(false) - - tool := NewSourcegraphTool() - params := SourcegraphParams{ - Query: "test query", - } - - paramsJSON, err := json.Marshal(params) - require.NoError(t, err) - - call := ToolCall{ - Name: SourcegraphToolName, - Input: string(paramsJSON), - } - - response, err := tool.Run(context.Background(), call) - require.NoError(t, err) - assert.Contains(t, response.Content, "Permission denied") - }) - t.Run("normalizes count parameter", func(t *testing.T) { // Test cases for count normalization testCases := []struct { -- cgit v1.2.3