github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/command/license_get_test.go (about) 1 package command 2 3 import ( 4 "testing" 5 6 "github.com/mitchellh/cli" 7 "github.com/stretchr/testify/require" 8 ) 9 10 var _ cli.Command = &LicenseGetCommand{} 11 12 func TestCommand_LicenseGet_OSSErr(t *testing.T) { 13 t.Parallel() 14 15 srv, _, url := testServer(t, false, nil) 16 defer srv.Shutdown() 17 18 ui := new(cli.MockUi) 19 cmd := &LicenseGetCommand{Meta: Meta{Ui: ui}} 20 21 code := cmd.Run([]string{"-address=" + url}) 22 if srv.Enterprise { 23 require.Equal(t, 0, code) 24 require.Contains(t, ui.OutputWriter.String(), "License Status = valid") 25 } else { 26 require.Equal(t, 1, code) 27 require.Contains(t, ui.ErrorWriter.String(), "Nomad Enterprise only endpoint") 28 } 29 }