mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-30 21:49:53 +00:00
structure tools the same
- add some tests - fix some tests - change how we handle permissions
This commit is contained in:
parent
5acf0cba60
commit
94923948e1
20 changed files with 1210 additions and 910 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue