Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/cli. OpenStatus CLI www.openstatus.dev
Something went wrong. Try again.
Go
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586package cmd_test
import ( "testing"
"github.com/openstatusHQ/cli/internal/cmd" "github.com/openstatusHQ/cli/internal/version")
func Test_NewApp(t *testing.T) { t.Parallel()
t.Run("Returns valid app command", func(t *testing.T) { app := cmd.NewApp()
if app == nil { t.Fatal("Expected non-nil app") }
if app.Name != "openstatus" { t.Errorf("Expected app name 'openstatus', got %s", app.Name) }
if app.Version != version.Version { t.Errorf("Expected version %q, got %s", version.Version, app.Version) }
if !app.Suggest { t.Error("Expected Suggest to be true") } })
t.Run("Has expected commands", func(t *testing.T) { app := cmd.NewApp()
if len(app.Commands) != 13 { t.Errorf("Expected 13 commands, got %d", len(app.Commands)) }
expectedCommands := map[string]bool{ "check": false, "monitors": false, "status-report": false, "incident": false, "maintenance": false, "status-page": false, "notification": false, "private-locations": false, "run": false, "whoami": false, "login": false, "logout": false, "terraform": false, }
for _, subcmd := range app.Commands { if _, exists := expectedCommands[subcmd.Name]; exists { expectedCommands[subcmd.Name] = true } }
for name, found := range expectedCommands { if !found { t.Errorf("Expected command '%s' not found", name) } } })
t.Run("Has correct usage text", func(t *testing.T) { app := cmd.NewApp()
expectedUsage := "Manage status pages, monitors, and incidents from the terminal" if app.Usage != expectedUsage { t.Errorf("Expected usage '%s', got '%s'", expectedUsage, app.Usage) } })
t.Run("Has description", func(t *testing.T) { app := cmd.NewApp()
if app.Description == "" { t.Error("Expected non-empty description") } })}