github.com/ilhicas/nomad@v0.11.8/command/license_put_test.go (about)

     1  package command
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/mitchellh/cli"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  var _ cli.Command = &LicensePutCommand{}
    12  
    13  func TestCommand_LicensePut_Err(t *testing.T) {
    14  	t.Parallel()
    15  
    16  	srv, _, url := testServer(t, false, nil)
    17  	defer srv.Shutdown()
    18  
    19  	ui := new(cli.MockUi)
    20  	cmd := &LicensePutCommand{Meta: Meta{Ui: ui}, testStdin: strings.NewReader("testlicenseblob")}
    21  
    22  	if code := cmd.Run([]string{"-address=" + url, "-"}); code != 1 {
    23  		require.Equal(t, code, 1)
    24  	}
    25  
    26  	if srv.Enterprise {
    27  		require.Contains(t, ui.ErrorWriter.String(), "error validating license")
    28  	} else {
    29  		require.Contains(t, ui.ErrorWriter.String(), "Nomad Enterprise only endpoint")
    30  	}
    31  
    32  }