github.com/ilhicas/nomad@v0.11.8/command/operator_keygen_test.go (about) 1 package command 2 3 import ( 4 "encoding/base64" 5 "testing" 6 7 "github.com/mitchellh/cli" 8 ) 9 10 func TestKeygenCommand(t *testing.T) { 11 t.Parallel() 12 ui := new(cli.MockUi) 13 c := &OperatorKeygenCommand{Meta: Meta{Ui: ui}} 14 code := c.Run(nil) 15 if code != 0 { 16 t.Fatalf("bad: %d", code) 17 } 18 19 output := ui.OutputWriter.String() 20 result, err := base64.StdEncoding.DecodeString(output) 21 if err != nil { 22 t.Fatalf("err: %s", err) 23 } 24 25 if len(result) != 16 { 26 t.Fatalf("bad: %#v", result) 27 } 28 }