MCPcopy Create free account
hub / github.com/github/gh-aw / TestParseBashToolWithBoolean

Function TestParseBashToolWithBoolean

pkg/workflow/tools_validation_test.go:78–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76}
77
78func 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
126func TestNewToolsWithInvalidBash(t *testing.T) {
127 t.Run("detects invalid bash configuration", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

parseBashToolFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected