2026-04-10 07:34:33 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestAppRunRejectsUnknownCommand(t *testing.T) {
|
2026-04-10 07:40:23 +00:00
|
|
|
app := NewApp()
|
2026-04-10 07:34:33 +00:00
|
|
|
|
|
|
|
|
err := app.Run([]string{"unknown"})
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("expected error for unknown command")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) {
|
2026-04-10 07:40:23 +00:00
|
|
|
app := NewApp()
|
2026-04-10 07:34:33 +00:00
|
|
|
|
|
|
|
|
err := app.Run(nil)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("expected error for missing command")
|
|
|
|
|
}
|
|
|
|
|
if !strings.Contains(err.Error(), "usage:") {
|
|
|
|
|
t.Fatalf("expected usage text in error, got %q", err.Error())
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-10 07:40:23 +00:00
|
|
|
|
|
|
|
|
func TestAppRunAcceptsSetupAndMcp(t *testing.T) {
|
|
|
|
|
app := NewApp()
|
|
|
|
|
|
|
|
|
|
for _, command := range []string{"setup", "mcp"} {
|
|
|
|
|
t.Run(command, func(t *testing.T) {
|
|
|
|
|
if err := app.Run([]string{command}); err != nil {
|
|
|
|
|
t.Fatalf("expected %q to be accepted, got error: %v", command, err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|