mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-21 21:05:09 +00:00
- Return "unknown" for unrecognized args in commandName to avoid
sending arbitrary user input to PostHog
- Revert goreleaser to {{ .Env.POSTHOG_API_KEY }} (intentional hard
fail — release builds must have the key set)
- go mod tidy to fix posthog-go direct/indirect marker
- Add POSTHOG_API_KEY to .env.production.example
26 lines
668 B
Go
26 lines
668 B
Go
package cmd
|
|
|
|
import "testing"
|
|
|
|
func TestCommandName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
args []string
|
|
want string
|
|
}{
|
|
{"empty args", nil, "unknown"},
|
|
{"known command", []string{"health"}, "browseros-cli health"},
|
|
{"unknown command", []string{"nonexistent"}, "unknown"},
|
|
{"subcommand", []string{"bookmark", "search"}, "browseros-cli bookmark search"},
|
|
{"known with extra args", []string{"snap", "--enhanced"}, "browseros-cli snap"},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := commandName(tt.args)
|
|
if got != tt.want {
|
|
t.Errorf("commandName(%v) = %q, want %q", tt.args, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|