package commands import "testing" func TestParseSupportedCommandsAndAliases(t *testing.T) { aliases := map[string]bool{"codex": true, "codex-bot": true} cases := []struct{ body, name, mode string }{ {"@codex review", "review", "summary"}, {"@codex review security --full", "review", "full"}, {"@codex review tests", "review", "tests"}, {"@codex-bot explain", "explain", "summary"}, {"@codex --help", "help", ""}, } for _, tc := range cases { got, ok := Parse(tc.body, aliases) if !ok || got.Name != tc.name || got.Mode != tc.mode { t.Fatalf("Parse(%q) = %#v, %v", tc.body, got, ok) } } } func TestParsePreservesRawAndQuotedArguments(t *testing.T) { got, ok := Parse("@codex review \"focus auth\" --full\nsecond line", map[string]bool{"codex": true}) if !ok || got.Raw != "@codex review \"focus auth\" --full\nsecond line" { t.Fatalf("raw command was not preserved: %#v", got) } if len(got.Arguments) != 4 || got.Arguments[0] != "focus auth" || got.Arguments[1] != "--full" || got.Arguments[2] != "second" || got.Arguments[3] != "line" { t.Fatalf("arguments were not lexed: %#v", got.Arguments) } } func TestUnsupportedAndInlineCommands(t *testing.T) { if _, ok := Parse("@codex fix", map[string]bool{"codex": true}); ok { t.Fatal("fix must remain unsupported") } if DetectPrefixedCommand("Please run @codex review", map[string]bool{"codex": true}) != "" { t.Fatal("inline mention must not trigger") } if DetectPrefixedCommand("@codex deploy now", map[string]bool{"codex": true}) != "deploy" { t.Fatal("unsupported prefix was not detected") } }