2020-04-21 18:55:31 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2020-04-21 19:59:39 +00:00
|
|
|
"strings"
|
2020-04-21 18:55:31 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mitchellh/cli"
|
2020-04-21 19:59:39 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2020-04-21 18:55:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ cli.Command = &LicensePutCommand{}
|
|
|
|
|
2020-04-28 19:28:35 +00:00
|
|
|
func TestCommand_LicensePut_Err(t *testing.T) {
|
2020-04-21 19:59:39 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
srv, _, url := testServer(t, false, nil)
|
|
|
|
defer srv.Shutdown()
|
|
|
|
|
2020-10-05 14:07:41 +00:00
|
|
|
ui := cli.NewMockUi()
|
2020-04-21 19:59:39 +00:00
|
|
|
cmd := &LicensePutCommand{Meta: Meta{Ui: ui}, testStdin: strings.NewReader("testlicenseblob")}
|
|
|
|
|
|
|
|
if code := cmd.Run([]string{"-address=" + url, "-"}); code != 1 {
|
|
|
|
require.Equal(t, code, 1)
|
|
|
|
}
|
|
|
|
|
2020-04-28 19:28:35 +00:00
|
|
|
if srv.Enterprise {
|
|
|
|
require.Contains(t, ui.ErrorWriter.String(), "error validating license")
|
|
|
|
} else {
|
|
|
|
require.Contains(t, ui.ErrorWriter.String(), "Nomad Enterprise only endpoint")
|
|
|
|
}
|
2020-04-21 19:59:39 +00:00
|
|
|
|
2020-04-21 18:55:31 +00:00
|
|
|
}
|