Merge pull request #9027 from hashicorp/f-gh-9026
cli: move tests to use NewMockUi func.
This commit is contained in:
commit
ffe6533ad1
|
@ -23,7 +23,7 @@ func TestACLBootstrapCommand(t *testing.T) {
|
|||
|
||||
assert.Nil(srv.RootToken)
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLBootstrapCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
code := cmd.Run([]string{"-address=" + url})
|
||||
|
@ -48,7 +48,7 @@ func TestACLBootstrapCommand_ExistingBootstrapToken(t *testing.T) {
|
|||
|
||||
assert.NotNil(srv.RootToken)
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLBootstrapCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
code := cmd.Run([]string{"-address=" + url})
|
||||
|
@ -66,7 +66,7 @@ func TestACLBootstrapCommand_NonACLServer(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLBootstrapCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
code := cmd.Run([]string{"-address=" + url})
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestACLPolicyApplyCommand(t *testing.T) {
|
|||
token := srv.RootToken
|
||||
assert.NotNil(token, "failed to bootstrap ACL token")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLPolicyApplyCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a test policy
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestACLPolicyDeleteCommand(t *testing.T) {
|
|||
policy.SetHash()
|
||||
assert.Nil(state.UpsertACLPolicies(1000, []*structs.ACLPolicy{policy}))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLPolicyDeleteCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Delete the policy without a valid token fails
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestACLPolicyInfoCommand(t *testing.T) {
|
|||
policy.SetHash()
|
||||
assert.Nil(state.UpsertACLPolicies(1000, []*structs.ACLPolicy{policy}))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLPolicyInfoCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Attempt to apply a policy without a valid management token
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestACLPolicyListCommand(t *testing.T) {
|
|||
policy.SetHash()
|
||||
assert.Nil(state.UpsertACLPolicies(1000, []*structs.ACLPolicy{policy}))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLPolicyListCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Attempt to list policies without a valid management token
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestACLTokenCreateCommand(t *testing.T) {
|
|||
token := srv.RootToken
|
||||
assert.NotNil(token, "failed to bootstrap ACL token")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLTokenCreateCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Request to create a new token without providing a valid management token
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestACLTokenDeleteCommand_ViaEnvVariable(t *testing.T) {
|
|||
token := srv.RootToken
|
||||
assert.NotNil(token, "failed to bootstrap ACL token")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLTokenDeleteCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
state := srv.Agent.Server().State()
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestACLTokenInfoCommand_ViaEnvVar(t *testing.T) {
|
|||
token := srv.RootToken
|
||||
assert.NotNil(token, "failed to bootstrap ACL token")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLTokenInfoCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a valid token
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestACLTokenListCommand(t *testing.T) {
|
|||
mockToken.SetHash()
|
||||
assert.Nil(state.UpsertACLTokens(1000, []*structs.ACLToken{mockToken}))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLTokenListCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Attempt to list tokens without a valid management token
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestACLTokenSelfCommand_ViaEnvVar(t *testing.T) {
|
|||
token := srv.RootToken
|
||||
assert.NotNil(token, "failed to bootstrap ACL token")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLTokenSelfCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a valid token
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestACLTokenUpdateCommand(t *testing.T) {
|
|||
token := srv.RootToken
|
||||
assert.NotNil(token, "failed to bootstrap ACL token")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ACLTokenUpdateCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
state := srv.Agent.Server().State()
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ func TestCommand_Args(t *testing.T) {
|
|||
for _, tc := range tcases {
|
||||
// Make a new command. We preemptively close the shutdownCh
|
||||
// so that the command exits immediately instead of blocking.
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
shutdownCh := make(chan struct{})
|
||||
close(shutdownCh)
|
||||
cmd := &Command{
|
||||
|
@ -120,7 +120,7 @@ func TestCommand_MetaConfigValidation(t *testing.T) {
|
|||
|
||||
// Make a new command. We preemptively close the shutdownCh
|
||||
// so that the command exits immediately instead of blocking.
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
shutdownCh := make(chan struct{})
|
||||
close(shutdownCh)
|
||||
cmd := &Command{
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestAgentInfoCommand_Run(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AgentInfoCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{"-address=" + url})
|
||||
|
@ -28,7 +28,7 @@ func TestAgentInfoCommand_Run(t *testing.T) {
|
|||
|
||||
func TestAgentInfoCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AgentInfoCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestMonitorCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &MonitorCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -68,7 +68,7 @@ func TestAllocExecCommand_Fails(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocExecCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run(c.args)
|
||||
|
@ -100,7 +100,7 @@ func TestAllocExecCommand_Fails(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("non existent task", func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocExecCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
jobID := "job1_sfx"
|
||||
|
@ -139,7 +139,7 @@ func TestAllocExecCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocExecCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
@ -193,7 +193,7 @@ func TestAllocExecCommand_Run(t *testing.T) {
|
|||
resp, _, err := client.Jobs().Register(job, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
evalUi := new(cli.MockUi)
|
||||
evalUi := cli.NewMockUi()
|
||||
code := waitForSuccess(evalUi, client, fullId, t, resp.EvalID)
|
||||
require.Equal(t, 0, code, "failed to get status - output: %v", evalUi.ErrorWriter.String())
|
||||
|
||||
|
@ -249,7 +249,7 @@ func TestAllocExecCommand_Run(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
t.Run("by id: "+c.name, func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
var stdout, stderr bufferCloser
|
||||
|
||||
cmd := &AllocExecCommand{
|
||||
|
@ -265,7 +265,7 @@ func TestAllocExecCommand_Run(t *testing.T) {
|
|||
assert.Equal(t, c.stderr, strings.TrimSpace(stderr.String()))
|
||||
})
|
||||
t.Run("by job: "+c.name, func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
var stdout, stderr bufferCloser
|
||||
|
||||
cmd := &AllocExecCommand{
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestFSCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocFSCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on lack of job ID
|
||||
|
@ -94,7 +94,7 @@ func TestFSCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocFSCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestLogsCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocLogsCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -76,7 +76,7 @@ func TestLogsCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocLogsCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestAllocRestartCommand_Fails(t *testing.T) {
|
|||
defer srv.Shutdown()
|
||||
|
||||
require := require.New(t)
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocRestartCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -113,7 +113,7 @@ func TestAllocRestartCommand_Run(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocRestartCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
jobID := "job1_sfx"
|
||||
|
@ -157,7 +157,7 @@ func TestAllocRestartCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocRestartCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestAllocSignalCommand_Fails(t *testing.T) {
|
|||
|
||||
require := require.New(t)
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocSignalCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on lack of alloc ID
|
||||
|
@ -62,7 +62,7 @@ func TestAllocSignalCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocSignalCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
@ -103,7 +103,7 @@ func TestAllocSignalCommand_Run(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocSignalCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
jobID := "job1_sfx"
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestAllocStatusCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -108,7 +108,7 @@ func TestAllocStatusCommand_LifecycleInfo(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
state := srv.Agent.Server().State()
|
||||
|
||||
|
@ -172,7 +172,7 @@ func TestAllocStatusCommand_Run(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
jobID := "job1_sfx"
|
||||
|
@ -268,7 +268,7 @@ func TestAllocStatusCommand_RescheduleInfo(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
// Test reschedule attempt info
|
||||
require := require.New(t)
|
||||
|
@ -317,7 +317,7 @@ func TestAllocStatusCommand_ScoreMetrics(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
// Test node metrics
|
||||
require := require.New(t)
|
||||
|
@ -365,7 +365,7 @@ func TestAllocStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
@ -439,7 +439,7 @@ func TestAllocStatusCommand_HostVolumes(t *testing.T) {
|
|||
require.NoError(t, state.UpsertJobSummary(1004, summary))
|
||||
require.NoError(t, state.UpsertAllocs(1005, []*structs.Allocation{alloc}))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
if code := cmd.Run([]string{"-address=" + url, "-verbose", alloc.ID}); code != 0 {
|
||||
t.Fatalf("expected exit 0, got: %d", code)
|
||||
|
@ -514,7 +514,7 @@ func TestAllocStatusCommand_CSIVolumes(t *testing.T) {
|
|||
require.NoError(t, state.UpsertJobSummary(1004, summary))
|
||||
require.NoError(t, state.UpsertAllocs(1005, []*structs.Allocation{alloc}))
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
if code := cmd.Run([]string{"-address=" + url, "-verbose", alloc.ID}); code != 0 {
|
||||
t.Fatalf("expected exit 0, got: %d", code)
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestAllocStop_Fails(t *testing.T) {
|
|||
defer srv.Shutdown()
|
||||
|
||||
require := require.New(t)
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStopCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -73,7 +73,7 @@ func TestAllocStop_Run(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AllocStopCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
jobID := "job1_sfx"
|
||||
|
|
|
@ -12,7 +12,7 @@ func TestAgentCheckCommand_ServerHealth(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &AgentCheckCommand{Meta: Meta{Ui: ui}}
|
||||
address := fmt.Sprintf("-address=%s", url)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestDeploymentFailCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentFailCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentFailCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestDeploymentFailCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentFailCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestDeploymentListCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentListCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentListCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestDeploymentPauseCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentPauseCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentPauseCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestDeploymentPauseCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentPauseCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestDeploymentPromoteCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentPromoteCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentPromoteCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestDeploymentPromoteCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentPromoteCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestDeploymentResumeCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentResumeCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentResumeCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestDeploymentResumeCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentResumeCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestDeploymentStatusCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentStatusCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -48,7 +48,7 @@ func TestDeploymentStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestDeploymentUnblockCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestDeploymentUnblockCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentUnblockCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Unblocks on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestDeploymentUnblockCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &DeploymentUnblockCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestEvalStatusCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &EvalStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -68,7 +68,7 @@ func TestEvalStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &EvalStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake eval
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestHelpers_NodeID(t *testing.T) {
|
|||
srv, _, _ := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
meta := Meta{Ui: new(cli.MockUi)}
|
||||
meta := Meta{Ui: cli.NewMockUi()}
|
||||
client, err := meta.Client()
|
||||
if err != nil {
|
||||
t.FailNow()
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestJobDeploymentsCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobDeploymentsCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobDeploymentsCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -44,7 +44,7 @@ func TestJobDeploymentsCommand_Run(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobDeploymentsCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Should return an error message for no job match
|
||||
|
@ -88,7 +88,7 @@ func TestJobDeploymentsCommand_Run_Latest(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobDeploymentsCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Should return an error message for no job match
|
||||
|
@ -133,7 +133,7 @@ func TestJobDeploymentsCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobDeploymentsCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestJobDispatchCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobDispatchCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobDispatchCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -54,7 +54,7 @@ func TestJobDispatchCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobDispatchCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestJobEvalCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobEvalCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobEvalCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -66,7 +66,7 @@ func TestJobEvalCommand_Run(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobEvalCommand{Meta: Meta{Ui: ui}}
|
||||
require := require.New(t)
|
||||
|
||||
|
@ -109,7 +109,7 @@ func TestJobEvalCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobEvalCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestJobHistoryCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobHistoryCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobHistoryCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestJobHistoryCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobHistoryCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestInitCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestInitCommand_Run(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobInitCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -91,7 +91,7 @@ func TestInitCommand_defaultJob(t *testing.T) {
|
|||
|
||||
func TestInitCommand_customFilename(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobInitCommand{Meta: Meta{Ui: ui}}
|
||||
filename := "custom.nomad"
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestInspectCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -66,7 +66,7 @@ func TestInspectCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobInspectCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
state := srv.Agent.Server().State()
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestJobPeriodicForceCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobPeriodicForceCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPeriodicForceCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -43,7 +43,7 @@ func TestJobPeriodicForceCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPeriodicForceCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job, not periodic
|
||||
|
@ -98,7 +98,7 @@ func TestJobPeriodicForceCommand_NonPeriodicJob(t *testing.T) {
|
|||
// Register a job
|
||||
j := testJob("job_not_periodic")
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPeriodicForceCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
resp, _, err := client.Jobs().Register(j, nil)
|
||||
|
@ -141,7 +141,7 @@ func TestJobPeriodicForceCommand_SuccessfulPeriodicForceDetach(t *testing.T) {
|
|||
TimeZone: helper.StringToPtr("Europe/Minsk"),
|
||||
}
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPeriodicForceCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
_, _, err := client.Jobs().Register(j, nil)
|
||||
|
@ -183,7 +183,7 @@ func TestJobPeriodicForceCommand_SuccessfulPeriodicForce(t *testing.T) {
|
|||
TimeZone: helper.StringToPtr("Europe/Minsk"),
|
||||
}
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPeriodicForceCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
_, _, err := client.Jobs().Register(j, nil)
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestPlanCommand_Fails(t *testing.T) {
|
|||
s := testutil.NewTestServer(t, nil)
|
||||
defer s.Stop()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPlanCommand{Meta: Meta{Ui: ui, flagAddress: "http://" + s.HTTPAddr}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -119,7 +119,7 @@ func TestPlanCommand_From_STDIN(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPlanCommand{
|
||||
Meta: Meta{Ui: ui},
|
||||
JobGetter: JobGetter{testStdin: stdinR},
|
||||
|
@ -157,7 +157,7 @@ job "job1" {
|
|||
|
||||
func TestPlanCommand_From_URL(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPlanCommand{
|
||||
Meta: Meta{Ui: ui},
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ func TestPlanCommand_From_URL(t *testing.T) {
|
|||
|
||||
func TestPlanCommad_Preemptions(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPlanCommand{Meta: Meta{Ui: ui}}
|
||||
require := require.New(t)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestJobPromoteCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobPromoteCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPromoteCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestJobPromoteCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobPromoteCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestJobRevertCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestJobRevertCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRevertCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestJobRevertCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRevertCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestRunCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestRunCommand_Output_Json(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRunCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
fh, err := ioutil.TempFile("", "nomad")
|
||||
|
@ -58,7 +58,7 @@ func TestRunCommand_Fails(t *testing.T) {
|
|||
s := testutil.NewTestServer(t, nil)
|
||||
defer s.Stop()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRunCommand{Meta: Meta{Ui: ui, flagAddress: "http://" + s.HTTPAddr}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -162,7 +162,7 @@ func TestRunCommand_From_STDIN(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRunCommand{
|
||||
Meta: Meta{Ui: ui},
|
||||
JobGetter: JobGetter{testStdin: stdinR},
|
||||
|
@ -200,7 +200,7 @@ job "job1" {
|
|||
|
||||
func TestRunCommand_From_URL(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRunCommand{
|
||||
Meta: Meta{Ui: ui},
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestJobStatusCommand_Run(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Should return blank for no jobs
|
||||
|
@ -220,7 +220,7 @@ func TestJobStatusCommand_Run(t *testing.T) {
|
|||
|
||||
func TestJobStatusCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -248,7 +248,7 @@ func TestJobStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
@ -303,7 +303,7 @@ func TestJobStatusCommand_WithAccessPolicy(t *testing.T) {
|
|||
|
||||
invalidToken := mock.ACLToken()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// registering a job without a token fails
|
||||
|
@ -353,7 +353,7 @@ func TestJobStatusCommand_RescheduleEvals(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
require := require.New(t)
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestStopCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStopCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -57,7 +57,7 @@ func TestStopCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobStopCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestValidateCommand(t *testing.T) {
|
|||
s := testutil.NewTestServer(t, nil)
|
||||
defer s.Stop()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobValidateCommand{Meta: Meta{Ui: ui, flagAddress: "http://" + s.HTTPAddr}}
|
||||
|
||||
fh, err := ioutil.TempFile("", "nomad")
|
||||
|
@ -57,7 +57,7 @@ job "job1" {
|
|||
|
||||
func TestValidateCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobValidateCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -124,7 +124,7 @@ func TestValidateCommand_From_STDIN(t *testing.T) {
|
|||
s := testutil.NewTestServer(t, nil)
|
||||
defer s.Stop()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobValidateCommand{
|
||||
Meta: Meta{Ui: ui, flagAddress: "http://" + s.HTTPAddr},
|
||||
JobGetter: JobGetter{testStdin: stdinR},
|
||||
|
@ -161,7 +161,7 @@ job "job1" {
|
|||
|
||||
func TestValidateCommand_From_URL(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRunCommand{
|
||||
Meta: Meta{Ui: ui},
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestCommand_LicenseGet_OSSErr(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &LicenseGetCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{"-address=" + url})
|
||||
|
@ -47,7 +47,7 @@ func TestOutputLicenseReply(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
|
||||
require.Equal(t, 0, OutputLicenseReply(ui, lic))
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestCommand_LicensePut_Err(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &LicensePutCommand{Meta: Meta{Ui: ui}, testStdin: strings.NewReader("testlicenseblob")}
|
||||
|
||||
if code := cmd.Run([]string{"-address=" + url, "-"}); code != 1 {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
func TestMonitor_Update_Eval(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
mon := newMonitor(ui, nil, fullId)
|
||||
|
||||
// Evals triggered by jobs log
|
||||
|
@ -65,7 +65,7 @@ func TestMonitor_Update_Eval(t *testing.T) {
|
|||
|
||||
func TestMonitor_Update_Allocs(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
mon := newMonitor(ui, nil, fullId)
|
||||
|
||||
// New allocations write new logs
|
||||
|
@ -136,7 +136,7 @@ func TestMonitor_Update_Allocs(t *testing.T) {
|
|||
|
||||
func TestMonitor_Update_AllocModification(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
mon := newMonitor(ui, nil, fullId)
|
||||
|
||||
// New allocs with a create index lower than the
|
||||
|
@ -176,7 +176,7 @@ func TestMonitor_Monitor(t *testing.T) {
|
|||
defer srv.Shutdown()
|
||||
|
||||
// Create the monitor
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
mon := newMonitor(ui, client, fullId)
|
||||
|
||||
// Submit a job - this creates a new evaluation we can monitor
|
||||
|
@ -223,7 +223,7 @@ func TestMonitor_MonitorWithPrefix(t *testing.T) {
|
|||
defer srv.Shutdown()
|
||||
|
||||
// Create the monitor
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
mon := newMonitor(ui, client, shortId)
|
||||
|
||||
// Submit a job - this creates a new evaluation we can monitor
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestNamespaceApplyCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestNamespaceApplyCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceApplyCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -45,7 +45,7 @@ func TestNamespaceApplyCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceApplyCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a namespace
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestNamespaceDeleteCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestNamespaceDeleteCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceDeleteCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -47,7 +47,7 @@ func TestNamespaceDeleteCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceDeleteCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a namespace to delete
|
||||
|
@ -74,7 +74,7 @@ func TestNamespaceDeleteCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceDeleteCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a namespace other than default
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestNamespaceInspectCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestNamespaceInspectCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -47,7 +47,7 @@ func TestNamespaceInspectCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a namespace
|
||||
|
@ -75,7 +75,7 @@ func TestNamespaceInspectCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceInspectCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a namespace
|
||||
|
@ -104,7 +104,7 @@ func TestNamespaceInspectCommand_NamespaceMatchesPrefix(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a namespace that uses foo as a prefix
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestNamespaceListCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestNamespaceListCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceListCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -44,7 +44,7 @@ func TestNamespaceListCommand_List(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceListCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// List should contain default deployment
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestNamespaceStatusCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestNamespaceStatusCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -47,7 +47,7 @@ func TestNamespaceStatusCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a namespace
|
||||
|
@ -76,7 +76,7 @@ func TestNamespaceStatusCommand_Good_Quota(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a quota to delete
|
||||
|
@ -116,7 +116,7 @@ func TestNamespaceStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a namespace
|
||||
|
@ -145,7 +145,7 @@ func TestNamespaceStatusCommand_NamespaceMatchesPrefix(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NamespaceStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a namespace that uses foo as a prefix
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestClientConfigCommand_UpdateServers(t *testing.T) {
|
|||
})
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeConfigCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails if trying to update with no servers
|
||||
|
@ -48,7 +48,7 @@ func TestClientConfigCommand_UpdateServers(t *testing.T) {
|
|||
|
||||
func TestClientConfigCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeConfigCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -80,7 +80,7 @@ func TestNodeDrainCommand_Detach(t *testing.T) {
|
|||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeDrainCommand{Meta: Meta{Ui: ui}}
|
||||
if code := cmd.Run([]string{"-address=" + url, "-self", "-enable", "-detach"}); code != 0 {
|
||||
t.Fatalf("expected exit 0, got: %d", code)
|
||||
|
@ -302,7 +302,7 @@ func TestNodeDrainCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeDrainCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -434,7 +434,7 @@ func TestNodeDrainCommand_AutocompleteArgs(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeDrainCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
prefix := nodeID[:len(nodeID)-5]
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestNodeEligibilityCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeEligibilityCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -112,7 +112,7 @@ func TestNodeEligibilityCommand_AutocompleteArgs(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeEligibilityCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
prefix := nodeID[:len(nodeID)-5]
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestNodeStatusCommand_Self(t *testing.T) {
|
|||
})
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Wait for a node to appear
|
||||
|
@ -78,7 +78,7 @@ func TestNodeStatusCommand_Run(t *testing.T) {
|
|||
})
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Wait for a node to appear
|
||||
|
@ -167,7 +167,7 @@ func TestNodeStatusCommand_Fails(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -238,7 +238,7 @@ func TestNodeStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
})
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &NodeStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
prefix := nodeID[:len(nodeID)-5]
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestOperatorAutopilotGetConfigCommand(t *testing.T) {
|
|||
s, _, addr := testServer(t, false, nil)
|
||||
defer s.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorAutopilotGetCommand{Meta: Meta{Ui: ui}}
|
||||
args := []string{"-address=" + addr}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestOperatorAutopilotSetConfigCommand(t *testing.T) {
|
|||
s, _, addr := testServer(t, false, nil)
|
||||
defer s.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorAutopilotSetCommand{Meta: Meta{Ui: ui}}
|
||||
args := []string{
|
||||
"-address=" + addr,
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestDebugFails(t *testing.T) {
|
|||
srv, _, _ := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorDebugCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails incorrect args
|
||||
|
@ -75,7 +75,7 @@ func TestDebugCapturedFiles(t *testing.T) {
|
|||
srv, _, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorDebugCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func TestKeygenCommand(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorKeygenCommand{Meta: Meta{Ui: ui}}
|
||||
code := c.Run(nil)
|
||||
if code != 0 {
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestOperator_Raft_ListPeers(t *testing.T) {
|
|||
s, _, addr := testServer(t, false, nil)
|
||||
defer s.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorRaftListCommand{Meta: Meta{Ui: ui}}
|
||||
args := []string{"-address=" + addr}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestOperator_Raft_RemovePeer(t *testing.T) {
|
|||
s, _, addr := testServer(t, false, nil)
|
||||
defer s.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorRaftRemoveCommand{Meta: Meta{Ui: ui}}
|
||||
args := []string{"-address=" + addr, "-peer-address=nope", "-peer-id=nope"}
|
||||
|
||||
|
@ -46,7 +46,7 @@ func TestOperator_Raft_RemovePeerAddress(t *testing.T) {
|
|||
s, _, addr := testServer(t, false, nil)
|
||||
defer s.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorRaftRemoveCommand{Meta: Meta{Ui: ui}}
|
||||
args := []string{"-address=" + addr, "-peer-address=nope"}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func TestOperator_Raft_RemovePeerID(t *testing.T) {
|
|||
s, _, addr := testServer(t, false, nil)
|
||||
defer s.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
c := &OperatorRaftRemoveCommand{Meta: Meta{Ui: ui}}
|
||||
args := []string{"-address=" + addr, "-peer-id=nope"}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestOperatorSnapshotInspect_Works(t *testing.T) {
|
|||
|
||||
snapPath := generateSnapshotFile(t, nil)
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{snapPath})
|
||||
|
@ -49,7 +49,7 @@ func TestOperatorSnapshotInspect_HandlesFailure(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
t.Run("not found", func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{filepath.Join(tmpDir, "foo")})
|
||||
|
@ -58,7 +58,7 @@ func TestOperatorSnapshotInspect_HandlesFailure(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("invalid file", func(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{filepath.Join(tmpDir, "invalid.snap")})
|
||||
|
@ -90,7 +90,7 @@ func generateSnapshotFile(t *testing.T, prepare func(srv *agent.TestAgent, clien
|
|||
prepare(srv, api, url)
|
||||
}
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotSaveCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
dest := filepath.Join(tmpDir, "backup.snap")
|
||||
|
|
|
@ -39,7 +39,7 @@ job "snapshot-test-job" {
|
|||
|
||||
}`
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &JobRunCommand{Meta: Meta{Ui: ui}}
|
||||
cmd.JobGetter.testStdin = strings.NewReader(sampleJob)
|
||||
|
||||
|
@ -63,7 +63,7 @@ job "snapshot-test-job" {
|
|||
require.NoError(t, err)
|
||||
require.Nil(t, j)
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotRestoreCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
code := cmd.Run([]string{"--address=" + url, snapshotPath})
|
||||
|
@ -79,7 +79,7 @@ job "snapshot-test-job" {
|
|||
func TestOperatorSnapshotRestore_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotRestoreCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestOperatorSnapshotSave_Works(t *testing.T) {
|
|||
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotSaveCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
dest := filepath.Join(tmpDir, "backup.snap")
|
||||
|
@ -53,7 +53,7 @@ func TestOperatorSnapshotSave_Works(t *testing.T) {
|
|||
func TestOperatorSnapshotSave_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &OperatorSnapshotSaveCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestPluginStatusCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestPluginStatusCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &PluginStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -35,7 +35,7 @@ func TestPluginStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &PluginStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a plugin
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestQuotaApplyCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestQuotaApplyCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaApplyCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestQuotaDeleteCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestQuotaDeleteCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaDeleteCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -48,7 +48,7 @@ func TestQuotaDeleteCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaDeleteCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a quota to delete
|
||||
|
@ -73,7 +73,7 @@ func TestQuotaDeleteCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaDeleteCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a quota
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestQuotaInitCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestQuotaInitCommand_Run_HCL(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaInitCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -68,7 +68,7 @@ func TestQuotaInitCommand_Run_HCL(t *testing.T) {
|
|||
|
||||
func TestQuotaInitCommand_Run_JSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaInitCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestQuotaInspectCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestQuotaInspectCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -46,7 +46,7 @@ func TestQuotaInspectCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaInspectCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a quota to delete
|
||||
|
@ -72,7 +72,7 @@ func TestQuotaInspectCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaInspectCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a quota
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestQuotaListCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestQuotaListCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaListCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -46,7 +46,7 @@ func TestQuotaListCommand_List(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaListCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a quota
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestQuotaStatusCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestQuotaStatusCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -46,7 +46,7 @@ func TestQuotaStatusCommand_Good(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Create a quota to delete
|
||||
|
@ -78,7 +78,7 @@ func TestQuotaStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, client, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &QuotaStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a quota
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestServerMembersCommand_Run(t *testing.T) {
|
|||
srv, client, url := testServer(t, false, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Get our own node name
|
||||
|
@ -48,7 +48,7 @@ func TestServerMembersCommand_Run(t *testing.T) {
|
|||
|
||||
func TestMembersCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -97,7 +97,7 @@ func TestServerMembersCommand_MultiRegion_Leave(t *testing.T) {
|
|||
if _, err := srv2.Agent.Server().Join([]string{addr}); err != nil {
|
||||
t.Fatalf("Join err: %v", err)
|
||||
}
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Get our own node name
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestStatusCommand_Run_JobStatus(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
@ -46,7 +46,7 @@ func TestStatusCommand_Run_JobStatus_MultiMatch(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create two fake jobs sharing a prefix
|
||||
|
@ -75,7 +75,7 @@ func TestStatusCommand_Run_EvalStatus(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake eval
|
||||
|
@ -104,7 +104,7 @@ func TestStatusCommand_Run_NodeStatus(t *testing.T) {
|
|||
})
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Wait for a node to appear
|
||||
|
@ -141,7 +141,7 @@ func TestStatusCommand_Run_AllocStatus(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake alloc
|
||||
|
@ -166,7 +166,7 @@ func TestStatusCommand_Run_DeploymentStatus(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake deployment
|
||||
|
@ -192,7 +192,7 @@ func TestStatusCommand_Run_NoPrefix(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
@ -218,7 +218,7 @@ func TestStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &StatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
// Create a fake job
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestSystemGCCommand_Good(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &SystemGCCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
if code := cmd.Run([]string{"-address=" + url}); code != 0 {
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestSystemReconcileSummariesCommand_Good(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &SystemReconcileSummariesCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
if code := cmd.Run([]string{"-address=" + url}); code != 0 {
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestCSIVolumeStatusCommand_Implements(t *testing.T) {
|
|||
|
||||
func TestCSIVolumeStatusCommand_Fails(t *testing.T) {
|
||||
t.Parallel()
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &VolumeStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
// Fails on misuse
|
||||
|
@ -35,7 +35,7 @@ func TestCSIVolumeStatusCommand_AutocompleteArgs(t *testing.T) {
|
|||
srv, _, url := testServer(t, true, nil)
|
||||
defer srv.Shutdown()
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
ui := cli.NewMockUi()
|
||||
cmd := &VolumeStatusCommand{Meta: Meta{Ui: ui, flagAddress: url}}
|
||||
|
||||
state := srv.Agent.Server().State()
|
||||
|
|
Loading…
Reference in New Issue