summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/tools/sourcegraph_test.go
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-17 00:00:19 +0200
committerKujtim Hoxha <[email protected]>2025-04-21 13:42:02 +0200
commit36172979b45facc8ccec6861f124193eaebc42e9 (patch)
tree41f7683c53bd1aaa550a7ec22e027e98c29e5d4e /internal/llm/tools/sourcegraph_test.go
parentcc07f7a186995f428436bc1adc66a264a95171a4 (diff)
downloadopencode-36172979b45facc8ccec6861f124193eaebc42e9.tar.gz
opencode-36172979b45facc8ccec6861f124193eaebc42e9.zip
Update agent prompt, improve TUI patch UI, remove obsolete tool tests
- Replace and expand agent coder prompt for clarity and safety - Add patch tool and TUI dialog support for patch diffs - Sort sidebar modified files by name - Remove Bash/Edit/Sourcegraph/Write tool tests 🤖 Generated with opencode Co-Authored-By: opencode <[email protected]>
Diffstat (limited to 'internal/llm/tools/sourcegraph_test.go')
-rw-r--r--internal/llm/tools/sourcegraph_test.go86
1 files changed, 0 insertions, 86 deletions
diff --git a/internal/llm/tools/sourcegraph_test.go b/internal/llm/tools/sourcegraph_test.go
deleted file mode 100644
index 89829aefc..000000000
--- a/internal/llm/tools/sourcegraph_test.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package tools
-
-import (
- "context"
- "encoding/json"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestSourcegraphTool_Info(t *testing.T) {
- tool := NewSourcegraphTool()
- info := tool.Info()
-
- assert.Equal(t, SourcegraphToolName, info.Name)
- assert.NotEmpty(t, info.Description)
- assert.Contains(t, info.Parameters, "query")
- assert.Contains(t, info.Parameters, "count")
- assert.Contains(t, info.Parameters, "timeout")
- assert.Contains(t, info.Required, "query")
-}
-
-func TestSourcegraphTool_Run(t *testing.T) {
- t.Run("handles missing query parameter", func(t *testing.T) {
- tool := NewSourcegraphTool()
- params := SourcegraphParams{
- 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, "Query parameter is required")
- })
-
- t.Run("handles invalid parameters", func(t *testing.T) {
- tool := NewSourcegraphTool()
- call := ToolCall{
- Name: SourcegraphToolName,
- Input: "invalid json",
- }
-
- response, err := tool.Run(context.Background(), call)
- require.NoError(t, err)
- assert.Contains(t, response.Content, "Failed to parse sourcegraph parameters")
- })
-
- t.Run("normalizes count parameter", func(t *testing.T) {
- // Test cases for count normalization
- testCases := []struct {
- name string
- inputCount int
- expectedCount int
- }{
- {"negative count", -5, 10}, // Should use default (10)
- {"zero count", 0, 10}, // Should use default (10)
- {"valid count", 50, 50}, // Should keep as is
- {"excessive count", 150, 100}, // Should cap at 100
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- // Verify count normalization logic directly
- assert.NotPanics(t, func() {
- // Apply the same normalization logic as in the tool
- normalizedCount := tc.inputCount
- if normalizedCount <= 0 {
- normalizedCount = 10
- } else if normalizedCount > 100 {
- normalizedCount = 100
- }
-
- assert.Equal(t, tc.expectedCount, normalizedCount)
- })
- })
- }
- })
-}