57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package quirks
|
|
|
|
import "testing"
|
|
|
|
func TestShellInvokesNativeTool(t *testing.T) {
|
|
tools := []string{"shell", "client_9p", "file_read", "file_edit", "skill_list", "memory_wake"}
|
|
|
|
tests := []struct {
|
|
cmd string
|
|
want string
|
|
}{
|
|
// Should match: tool in command position
|
|
{"client_9p read foo", "client_9p"},
|
|
{"file_read path=/tmp/x", "file_read"},
|
|
{"skill_list", "skill_list"},
|
|
{"echo hello | skill_list", "skill_list"},
|
|
{"echo hello && file_read foo", "file_read"},
|
|
{"echo hello || file_edit bar", "file_edit"},
|
|
{"echo hello; memory_wake", "memory_wake"},
|
|
{"./client_9p read foo", "client_9p"},
|
|
{"/usr/local/bin/client_9p read", "client_9p"},
|
|
{"../bin/file_read foo", "file_read"},
|
|
{"$(file_read foo)", "file_read"},
|
|
{"`skill_list`", "skill_list"},
|
|
|
|
// Should match: ollie-9p -> client_9p
|
|
{"ollie-9p read session/foo", "client_9p"},
|
|
{"echo x | ollie-9p write foo", "client_9p"},
|
|
|
|
// Should NOT match: tool name in arguments (not command position)
|
|
{"git commit -m 'use client_9p interface'", ""},
|
|
{"echo 'client_9p is great'", ""},
|
|
{"git commit -m 'add file_read support'", ""},
|
|
{"grep skill_list README.md", ""},
|
|
{"cat file_read.go", ""},
|
|
{"echo ollie-9p is the CLI", ""},
|
|
|
|
// Should NOT match: substring
|
|
{"my_client_9p_wrapper foo", ""},
|
|
|
|
// Should not match shell itself
|
|
{"shell command", ""},
|
|
|
|
// Edge cases
|
|
{"", ""},
|
|
{"ls -la", ""},
|
|
{"go build ./...", ""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
got := ShellInvokesNativeTool(tt.cmd, tools)
|
|
if got != tt.want {
|
|
t.Errorf("ShellInvokesNativeTool(%q) = %q, want %q", tt.cmd, got, tt.want)
|
|
}
|
|
}
|
|
}
|