(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func TestParseBashToolWithBoolean(t *testing.T) { |
| 79 | tests := []struct { |
| 80 | name string |
| 81 | input any |
| 82 | expected *BashToolConfig |
| 83 | }{ |
| 84 | { |
| 85 | name: "bash: true enables all commands", |
| 86 | input: true, |
| 87 | expected: &BashToolConfig{AllowedCommands: nil}, |
| 88 | }, |
| 89 | { |
| 90 | name: "bash: false explicitly disables", |
| 91 | input: false, |
| 92 | expected: &BashToolConfig{AllowedCommands: []string{}}, |
| 93 | }, |
| 94 | { |
| 95 | name: "bash: nil is invalid", |
| 96 | input: nil, |
| 97 | expected: nil, |
| 98 | }, |
| 99 | { |
| 100 | name: "bash with array", |
| 101 | input: []any{"echo", "ls"}, |
| 102 | expected: &BashToolConfig{ |
| 103 | AllowedCommands: []string{"echo", "ls"}, |
| 104 | }, |
| 105 | }, |
| 106 | } |
| 107 | |
| 108 | for _, tt := range tests { |
| 109 | t.Run(tt.name, func(t *testing.T) { |
| 110 | result := parseBashTool(tt.input) |
| 111 | |
| 112 | if tt.expected == nil { |
| 113 | assert.Nil(t, result, "Expected nil result") |
| 114 | } else { |
| 115 | require.NotNil(t, result, "Expected non-nil result") |
| 116 | if tt.expected.AllowedCommands == nil { |
| 117 | assert.Nil(t, result.AllowedCommands, "Expected nil AllowedCommands (all allowed)") |
| 118 | } else { |
| 119 | assert.Equal(t, tt.expected.AllowedCommands, result.AllowedCommands, "AllowedCommands should match") |
| 120 | } |
| 121 | } |
| 122 | }) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | func TestNewToolsWithInvalidBash(t *testing.T) { |
| 127 | t.Run("detects invalid bash configuration", func(t *testing.T) { |
nothing calls this directly
no test coverage detected