github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/command/quota_apply_test.go (about) 1 package command 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/hashicorp/nomad/ci" 8 "github.com/mitchellh/cli" 9 ) 10 11 func TestQuotaApplyCommand_Implements(t *testing.T) { 12 ci.Parallel(t) 13 var _ cli.Command = &QuotaApplyCommand{} 14 } 15 16 func TestQuotaApplyCommand_Fails(t *testing.T) { 17 ci.Parallel(t) 18 ui := cli.NewMockUi() 19 cmd := &QuotaApplyCommand{Meta: Meta{Ui: ui}} 20 21 // Fails on misuse 22 if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 { 23 t.Fatalf("expected exit code 1, got: %d", code) 24 } 25 if out := ui.ErrorWriter.String(); !strings.Contains(out, commandErrorText(cmd)) { 26 t.Fatalf("expected help output, got: %s", out) 27 } 28 ui.ErrorWriter.Reset() 29 30 if code := cmd.Run([]string{"-address=nope"}); code != 1 { 31 t.Fatalf("expected exit code 1, got: %d", code) 32 } 33 if out := ui.ErrorWriter.String(); !strings.Contains(out, commandErrorText(cmd)) { 34 t.Fatalf("name required error, got: %s", out) 35 } 36 ui.ErrorWriter.Reset() 37 }