27 lines
545 B
Go
27 lines
545 B
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAppRunRejectsUnknownCommand(t *testing.T) {
|
|
app := NewApp(nil, nil, nil, nil)
|
|
|
|
err := app.Run([]string{"unknown"})
|
|
if err == nil {
|
|
t.Fatal("expected error for unknown command")
|
|
}
|
|
}
|
|
|
|
func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) {
|
|
app := NewApp(nil, nil, nil, nil)
|
|
|
|
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())
|
|
}
|
|
}
|