open-nomad/command/operator_client_state_test.go
Dao Thanh Tung 09b25d71b8
cli: Add a nomad operator client state command (#15469)
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
2023-01-11 10:03:31 -05:00

30 lines
685 B
Go

package command
import (
"strings"
"testing"
"github.com/hashicorp/nomad/ci"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/require"
)
func TestOperatorClientStateCommand(t *testing.T) {
ci.Parallel(t)
ui := cli.NewMockUi()
cmd := &OperatorClientStateCommand{Meta: Meta{Ui: ui}}
failedCode := cmd.Run([]string{"some", "bad", "args"})
require.Equal(t, 1, failedCode)
if out := ui.ErrorWriter.String(); !strings.Contains(out, commandErrorText(cmd)) {
t.Fatalf("expected help output, got: %s", out)
}
ui.ErrorWriter.Reset()
dir := t.TempDir()
code := cmd.Run([]string{dir})
require.Equal(t, 0, code)
require.Contains(t, ui.OutputWriter.String(), "{}")
}