2020-04-22 13:42:25 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ cli.Command = &LicenseGetCommand{}
|
|
|
|
|
|
|
|
func TestCommand_LicenseGet_OSSErr(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
srv, _, url := testServer(t, false, nil)
|
|
|
|
defer srv.Shutdown()
|
|
|
|
|
|
|
|
ui := new(cli.MockUi)
|
|
|
|
cmd := &LicenseGetCommand{Meta: Meta{Ui: ui}}
|
|
|
|
|
2020-04-30 12:56:40 +00:00
|
|
|
code := cmd.Run([]string{"-address=" + url})
|
|
|
|
if srv.Enterprise {
|
2020-05-05 14:28:58 +00:00
|
|
|
require.Equal(t, 0, code)
|
|
|
|
require.Contains(t, ui.OutputWriter.String(), "License Status = valid")
|
2020-04-30 12:56:40 +00:00
|
|
|
} else {
|
2020-05-05 14:28:58 +00:00
|
|
|
require.Equal(t, 1, code)
|
2020-04-30 12:56:40 +00:00
|
|
|
require.Contains(t, ui.ErrorWriter.String(), "Nomad Enterprise only endpoint")
|
|
|
|
}
|
2020-04-22 13:42:25 +00:00
|
|
|
}
|