github.com/s-matyukevich/consul@v1.4.5/command/keygen/keygen_test.go (about) 1 package keygen 2 3 import ( 4 "encoding/base64" 5 "strings" 6 "testing" 7 8 "github.com/mitchellh/cli" 9 ) 10 11 func TestKeygenCommand_noTabs(t *testing.T) { 12 t.Parallel() 13 if strings.ContainsRune(New(nil).Help(), '\t') { 14 t.Fatal("help has tabs") 15 } 16 } 17 18 func TestKeygenCommand(t *testing.T) { 19 t.Parallel() 20 ui := cli.NewMockUi() 21 cmd := New(ui) 22 code := cmd.Run(nil) 23 if code != 0 { 24 t.Fatalf("bad: %d", code) 25 } 26 27 output := ui.OutputWriter.String() 28 result, err := base64.StdEncoding.DecodeString(output) 29 if err != nil { 30 t.Fatalf("err: %s", err) 31 } 32 33 if len(result) != 16 { 34 t.Fatalf("bad: %#v", result) 35 } 36 }