github.com/hernad/nomad@v1.6.112/command/operator_gossip_keyring_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package command
     5  
     6  import (
     7  	"encoding/base64"
     8  	"testing"
     9  
    10  	"github.com/hernad/nomad/ci"
    11  	"github.com/mitchellh/cli"
    12  )
    13  
    14  func TestGossipKeyringGenerateCommand(t *testing.T) {
    15  	ci.Parallel(t)
    16  
    17  	ui := cli.NewMockUi()
    18  	c := &OperatorGossipKeyringGenerateCommand{Meta: Meta{Ui: ui}}
    19  	code := c.Run(nil)
    20  	if code != 0 {
    21  		t.Fatalf("bad: %d", code)
    22  	}
    23  
    24  	output := ui.OutputWriter.String()
    25  	result, err := base64.StdEncoding.DecodeString(output)
    26  	if err != nil {
    27  		t.Fatalf("err: %s", err)
    28  	}
    29  
    30  	if len(result) != 32 {
    31  		t.Fatalf("bad: %#v", result)
    32  	}
    33  }