From f5567b3261c834080ca667ea810f798e37d5d145 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Mon, 5 Oct 2020 16:07:41 +0200 Subject: [PATCH] cli: move tests to use NewMockUi func. --- command/acl_bootstrap_test.go | 6 +++--- command/acl_policy_apply_test.go | 2 +- command/acl_policy_delete_test.go | 2 +- command/acl_policy_info_test.go | 2 +- command/acl_policy_list_test.go | 2 +- command/acl_token_create_test.go | 2 +- command/acl_token_delete_test.go | 2 +- command/acl_token_info_test.go | 2 +- command/acl_token_list_test.go | 2 +- command/acl_token_self_test.go | 2 +- command/acl_token_update_test.go | 2 +- command/agent/command_test.go | 4 ++-- command/agent_info_test.go | 4 ++-- command/agent_monitor_test.go | 2 +- command/alloc_exec_test.go | 12 ++++++------ command/alloc_fs_test.go | 4 ++-- command/alloc_logs_test.go | 4 ++-- command/alloc_restart_test.go | 6 +++--- command/alloc_signal_test.go | 6 +++--- command/alloc_status_test.go | 16 ++++++++-------- command/alloc_stop_test.go | 4 ++-- command/check_test.go | 2 +- command/deployment_fail_test.go | 4 ++-- command/deployment_list_test.go | 2 +- command/deployment_pause_test.go | 4 ++-- command/deployment_promote_test.go | 4 ++-- command/deployment_resume_test.go | 4 ++-- command/deployment_status_test.go | 4 ++-- command/deployment_unblock_test.go | 4 ++-- command/eval_status_test.go | 4 ++-- command/helpers_test.go | 2 +- command/job_deployments_test.go | 8 ++++---- command/job_dispatch_test.go | 4 ++-- command/job_eval_test.go | 6 +++--- command/job_history_test.go | 4 ++-- command/job_init_test.go | 4 ++-- command/job_inspect_test.go | 4 ++-- command/job_periodic_force_test.go | 10 +++++----- command/job_plan_test.go | 8 ++++---- command/job_promote_test.go | 4 ++-- command/job_revert_test.go | 4 ++-- command/job_run_test.go | 8 ++++---- command/job_status_test.go | 10 +++++----- command/job_stop_test.go | 4 ++-- command/job_validate_test.go | 8 ++++---- command/license_get_test.go | 4 ++-- command/license_put_test.go | 2 +- command/monitor_test.go | 10 +++++----- command/namespace_apply_test.go | 4 ++-- command/namespace_delete_test.go | 6 +++--- command/namespace_inspect_test.go | 8 ++++---- command/namespace_list_test.go | 4 ++-- command/namespace_status_test.go | 10 +++++----- command/node_config_test.go | 4 ++-- command/node_drain_test.go | 6 +++--- command/node_eligibility_test.go | 4 ++-- command/node_status_test.go | 8 ++++---- command/operator_autopilot_get_test.go | 2 +- command/operator_autopilot_set_test.go | 2 +- command/operator_debug_test.go | 4 ++-- command/operator_keygen_test.go | 2 +- command/operator_raft_list_test.go | 2 +- command/operator_raft_remove_test.go | 6 +++--- command/operator_snapshot_inspect_test.go | 8 ++++---- command/operator_snapshot_restore_test.go | 6 +++--- command/operator_snapshot_save_test.go | 4 ++-- command/plugin_status_test.go | 4 ++-- command/quota_apply_test.go | 2 +- command/quota_delete_test.go | 6 +++--- command/quota_init_test.go | 4 ++-- command/quota_inspect_test.go | 6 +++--- command/quota_list_test.go | 4 ++-- command/quota_status_test.go | 6 +++--- command/server_members_test.go | 6 +++--- command/status_test.go | 16 ++++++++-------- command/system_gc_test.go | 2 +- command/system_reconcile_summaries_test.go | 2 +- command/volume_status_test.go | 4 ++-- 78 files changed, 188 insertions(+), 188 deletions(-) diff --git a/command/acl_bootstrap_test.go b/command/acl_bootstrap_test.go index 02ed7bd28..9b029f07a 100644 --- a/command/acl_bootstrap_test.go +++ b/command/acl_bootstrap_test.go @@ -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}) diff --git a/command/acl_policy_apply_test.go b/command/acl_policy_apply_test.go index 475b41aaa..608dbf0e6 100644 --- a/command/acl_policy_apply_test.go +++ b/command/acl_policy_apply_test.go @@ -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 diff --git a/command/acl_policy_delete_test.go b/command/acl_policy_delete_test.go index 7477a7929..4c5bc80ac 100644 --- a/command/acl_policy_delete_test.go +++ b/command/acl_policy_delete_test.go @@ -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 diff --git a/command/acl_policy_info_test.go b/command/acl_policy_info_test.go index 932eae2f6..7c2452c55 100644 --- a/command/acl_policy_info_test.go +++ b/command/acl_policy_info_test.go @@ -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 diff --git a/command/acl_policy_list_test.go b/command/acl_policy_list_test.go index f1f2a4e09..36f9f08e5 100644 --- a/command/acl_policy_list_test.go +++ b/command/acl_policy_list_test.go @@ -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 diff --git a/command/acl_token_create_test.go b/command/acl_token_create_test.go index 42879c2bf..7d8c59f6c 100644 --- a/command/acl_token_create_test.go +++ b/command/acl_token_create_test.go @@ -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 diff --git a/command/acl_token_delete_test.go b/command/acl_token_delete_test.go index bd9e6ae79..6c0b2980e 100644 --- a/command/acl_token_delete_test.go +++ b/command/acl_token_delete_test.go @@ -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() diff --git a/command/acl_token_info_test.go b/command/acl_token_info_test.go index 92ef7b20d..0f10e0ae4 100644 --- a/command/acl_token_info_test.go +++ b/command/acl_token_info_test.go @@ -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 diff --git a/command/acl_token_list_test.go b/command/acl_token_list_test.go index 55f2fd9c5..1c09bee09 100644 --- a/command/acl_token_list_test.go +++ b/command/acl_token_list_test.go @@ -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 diff --git a/command/acl_token_self_test.go b/command/acl_token_self_test.go index 0c44923c8..d219815c1 100644 --- a/command/acl_token_self_test.go +++ b/command/acl_token_self_test.go @@ -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 diff --git a/command/acl_token_update_test.go b/command/acl_token_update_test.go index 478f6f4e6..3af60f941 100644 --- a/command/acl_token_update_test.go +++ b/command/acl_token_update_test.go @@ -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() diff --git a/command/agent/command_test.go b/command/agent/command_test.go index eed6bba82..4a0522b3f 100644 --- a/command/agent/command_test.go +++ b/command/agent/command_test.go @@ -65,7 +65,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{ @@ -119,7 +119,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{ diff --git a/command/agent_info_test.go b/command/agent_info_test.go index 9099729aa..83f46038c 100644 --- a/command/agent_info_test.go +++ b/command/agent_info_test.go @@ -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 diff --git a/command/agent_monitor_test.go b/command/agent_monitor_test.go index 3a31fc6c6..ba5a2a5b7 100644 --- a/command/agent_monitor_test.go +++ b/command/agent_monitor_test.go @@ -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 diff --git a/command/alloc_exec_test.go b/command/alloc_exec_test.go index 3c064cef8..e7a72c497 100644 --- a/command/alloc_exec_test.go +++ b/command/alloc_exec_test.go @@ -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{ diff --git a/command/alloc_fs_test.go b/command/alloc_fs_test.go index d713a74b9..46e0875c1 100644 --- a/command/alloc_fs_test.go +++ b/command/alloc_fs_test.go @@ -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 diff --git a/command/alloc_logs_test.go b/command/alloc_logs_test.go index f567ae7bb..2ea0b282f 100644 --- a/command/alloc_logs_test.go +++ b/command/alloc_logs_test.go @@ -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 diff --git a/command/alloc_restart_test.go b/command/alloc_restart_test.go index 6c6f2a289..7ce03f6a6 100644 --- a/command/alloc_restart_test.go +++ b/command/alloc_restart_test.go @@ -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 diff --git a/command/alloc_signal_test.go b/command/alloc_signal_test.go index 87cdb46fb..e9e36c058 100644 --- a/command/alloc_signal_test.go +++ b/command/alloc_signal_test.go @@ -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" diff --git a/command/alloc_status_test.go b/command/alloc_status_test.go index 32006d0c1..c82946d1e 100644 --- a/command/alloc_status_test.go +++ b/command/alloc_status_test.go @@ -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) diff --git a/command/alloc_stop_test.go b/command/alloc_stop_test.go index f46532ef8..55d4cd1cc 100644 --- a/command/alloc_stop_test.go +++ b/command/alloc_stop_test.go @@ -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" diff --git a/command/check_test.go b/command/check_test.go index 4f3e81aac..ecc47abdd 100644 --- a/command/check_test.go +++ b/command/check_test.go @@ -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) diff --git a/command/deployment_fail_test.go b/command/deployment_fail_test.go index e5d5047fc..0cc8af90c 100644 --- a/command/deployment_fail_test.go +++ b/command/deployment_fail_test.go @@ -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 diff --git a/command/deployment_list_test.go b/command/deployment_list_test.go index 66262579a..433fa67a8 100644 --- a/command/deployment_list_test.go +++ b/command/deployment_list_test.go @@ -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 diff --git a/command/deployment_pause_test.go b/command/deployment_pause_test.go index 7d89c7adf..1b0c5094e 100644 --- a/command/deployment_pause_test.go +++ b/command/deployment_pause_test.go @@ -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 diff --git a/command/deployment_promote_test.go b/command/deployment_promote_test.go index aa7976c24..9e9afd8e7 100644 --- a/command/deployment_promote_test.go +++ b/command/deployment_promote_test.go @@ -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 diff --git a/command/deployment_resume_test.go b/command/deployment_resume_test.go index 1cac0518e..605f82f64 100644 --- a/command/deployment_resume_test.go +++ b/command/deployment_resume_test.go @@ -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 diff --git a/command/deployment_status_test.go b/command/deployment_status_test.go index 89ad05f4a..e083344fd 100644 --- a/command/deployment_status_test.go +++ b/command/deployment_status_test.go @@ -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 diff --git a/command/deployment_unblock_test.go b/command/deployment_unblock_test.go index 72adc8be9..a55ec7259 100644 --- a/command/deployment_unblock_test.go +++ b/command/deployment_unblock_test.go @@ -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 diff --git a/command/eval_status_test.go b/command/eval_status_test.go index c6f965797..2c37a8ebc 100644 --- a/command/eval_status_test.go +++ b/command/eval_status_test.go @@ -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 diff --git a/command/helpers_test.go b/command/helpers_test.go index 139acd307..553f822f8 100644 --- a/command/helpers_test.go +++ b/command/helpers_test.go @@ -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() diff --git a/command/job_deployments_test.go b/command/job_deployments_test.go index 448ddab4b..fb365caf4 100644 --- a/command/job_deployments_test.go +++ b/command/job_deployments_test.go @@ -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 diff --git a/command/job_dispatch_test.go b/command/job_dispatch_test.go index 8034e6e78..b6b36e8c5 100644 --- a/command/job_dispatch_test.go +++ b/command/job_dispatch_test.go @@ -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 diff --git a/command/job_eval_test.go b/command/job_eval_test.go index ef5019e36..4f6dca71b 100644 --- a/command/job_eval_test.go +++ b/command/job_eval_test.go @@ -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 diff --git a/command/job_history_test.go b/command/job_history_test.go index 05088d519..13be00b29 100644 --- a/command/job_history_test.go +++ b/command/job_history_test.go @@ -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 diff --git a/command/job_init_test.go b/command/job_init_test.go index 023d4e2e2..35575c657 100644 --- a/command/job_init_test.go +++ b/command/job_init_test.go @@ -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" diff --git a/command/job_inspect_test.go b/command/job_inspect_test.go index d369c7cfb..6d4e22166 100644 --- a/command/job_inspect_test.go +++ b/command/job_inspect_test.go @@ -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() diff --git a/command/job_periodic_force_test.go b/command/job_periodic_force_test.go index fc8caedc6..dd57623ae 100644 --- a/command/job_periodic_force_test.go +++ b/command/job_periodic_force_test.go @@ -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) diff --git a/command/job_plan_test.go b/command/job_plan_test.go index 09081107b..be0b5ac2b 100644 --- a/command/job_plan_test.go +++ b/command/job_plan_test.go @@ -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) diff --git a/command/job_promote_test.go b/command/job_promote_test.go index 50ead0d02..22d51c781 100644 --- a/command/job_promote_test.go +++ b/command/job_promote_test.go @@ -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 diff --git a/command/job_revert_test.go b/command/job_revert_test.go index 450df93f1..c968b4c80 100644 --- a/command/job_revert_test.go +++ b/command/job_revert_test.go @@ -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 diff --git a/command/job_run_test.go b/command/job_run_test.go index 32fe5b9a4..cb860cc81 100644 --- a/command/job_run_test.go +++ b/command/job_run_test.go @@ -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}, } diff --git a/command/job_status_test.go b/command/job_status_test.go index 745af018e..10056e495 100644 --- a/command/job_status_test.go +++ b/command/job_status_test.go @@ -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) diff --git a/command/job_stop_test.go b/command/job_stop_test.go index 528faf0ce..effc00bbc 100644 --- a/command/job_stop_test.go +++ b/command/job_stop_test.go @@ -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 diff --git a/command/job_validate_test.go b/command/job_validate_test.go index e2c85e27c..c6effae07 100644 --- a/command/job_validate_test.go +++ b/command/job_validate_test.go @@ -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}, } diff --git a/command/license_get_test.go b/command/license_get_test.go index 855af0d6b..22ca08b25 100644 --- a/command/license_get_test.go +++ b/command/license_get_test.go @@ -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)) diff --git a/command/license_put_test.go b/command/license_put_test.go index 71858c7ef..4bb8e6e75 100644 --- a/command/license_put_test.go +++ b/command/license_put_test.go @@ -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 { diff --git a/command/monitor_test.go b/command/monitor_test.go index 9c2d9c645..8f2719c59 100644 --- a/command/monitor_test.go +++ b/command/monitor_test.go @@ -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 diff --git a/command/namespace_apply_test.go b/command/namespace_apply_test.go index 5aebff376..d4d7bd09e 100644 --- a/command/namespace_apply_test.go +++ b/command/namespace_apply_test.go @@ -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 diff --git a/command/namespace_delete_test.go b/command/namespace_delete_test.go index f8fe99ef3..8c187e232 100644 --- a/command/namespace_delete_test.go +++ b/command/namespace_delete_test.go @@ -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 diff --git a/command/namespace_inspect_test.go b/command/namespace_inspect_test.go index 6516dbb71..7f4862a63 100644 --- a/command/namespace_inspect_test.go +++ b/command/namespace_inspect_test.go @@ -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 diff --git a/command/namespace_list_test.go b/command/namespace_list_test.go index 2c74ff0f1..95b018333 100644 --- a/command/namespace_list_test.go +++ b/command/namespace_list_test.go @@ -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 diff --git a/command/namespace_status_test.go b/command/namespace_status_test.go index 229272893..fa4a387dd 100644 --- a/command/namespace_status_test.go +++ b/command/namespace_status_test.go @@ -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 diff --git a/command/node_config_test.go b/command/node_config_test.go index 31a845a56..c7dd3c57c 100644 --- a/command/node_config_test.go +++ b/command/node_config_test.go @@ -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 diff --git a/command/node_drain_test.go b/command/node_drain_test.go index 09c2d04a8..22aa5c2ed 100644 --- a/command/node_drain_test.go +++ b/command/node_drain_test.go @@ -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] diff --git a/command/node_eligibility_test.go b/command/node_eligibility_test.go index 92d0b06a0..2e9120d86 100644 --- a/command/node_eligibility_test.go +++ b/command/node_eligibility_test.go @@ -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] diff --git a/command/node_status_test.go b/command/node_status_test.go index 4aa7f550c..58dfb3e0f 100644 --- a/command/node_status_test.go +++ b/command/node_status_test.go @@ -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] diff --git a/command/operator_autopilot_get_test.go b/command/operator_autopilot_get_test.go index f8e4a9dc5..f5410b71d 100644 --- a/command/operator_autopilot_get_test.go +++ b/command/operator_autopilot_get_test.go @@ -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} diff --git a/command/operator_autopilot_set_test.go b/command/operator_autopilot_set_test.go index 515b5f7d8..9977abc40 100644 --- a/command/operator_autopilot_set_test.go +++ b/command/operator_autopilot_set_test.go @@ -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, diff --git a/command/operator_debug_test.go b/command/operator_debug_test.go index 3d18ab51d..37f048470 100644 --- a/command/operator_debug_test.go +++ b/command/operator_debug_test.go @@ -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{ diff --git a/command/operator_keygen_test.go b/command/operator_keygen_test.go index 22c57bff6..1f12eb3c4 100644 --- a/command/operator_keygen_test.go +++ b/command/operator_keygen_test.go @@ -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 { diff --git a/command/operator_raft_list_test.go b/command/operator_raft_list_test.go index 386c9f576..df283e88e 100644 --- a/command/operator_raft_list_test.go +++ b/command/operator_raft_list_test.go @@ -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} diff --git a/command/operator_raft_remove_test.go b/command/operator_raft_remove_test.go index 4d7516e33..886f07032 100644 --- a/command/operator_raft_remove_test.go +++ b/command/operator_raft_remove_test.go @@ -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"} diff --git a/command/operator_snapshot_inspect_test.go b/command/operator_snapshot_inspect_test.go index a394e657c..16a408942 100644 --- a/command/operator_snapshot_inspect_test.go +++ b/command/operator_snapshot_inspect_test.go @@ -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") diff --git a/command/operator_snapshot_restore_test.go b/command/operator_snapshot_restore_test.go index 1b448565a..f9b87e729 100644 --- a/command/operator_snapshot_restore_test.go +++ b/command/operator_snapshot_restore_test.go @@ -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 diff --git a/command/operator_snapshot_save_test.go b/command/operator_snapshot_save_test.go index 5a7ae490c..2e712db0c 100644 --- a/command/operator_snapshot_save_test.go +++ b/command/operator_snapshot_save_test.go @@ -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 diff --git a/command/plugin_status_test.go b/command/plugin_status_test.go index 0ad3717c2..e0cb4920d 100644 --- a/command/plugin_status_test.go +++ b/command/plugin_status_test.go @@ -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 diff --git a/command/quota_apply_test.go b/command/quota_apply_test.go index 4af13cffc..57b1b195c 100644 --- a/command/quota_apply_test.go +++ b/command/quota_apply_test.go @@ -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 diff --git a/command/quota_delete_test.go b/command/quota_delete_test.go index 254abc64c..91b0d042a 100644 --- a/command/quota_delete_test.go +++ b/command/quota_delete_test.go @@ -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 diff --git a/command/quota_init_test.go b/command/quota_init_test.go index 16e9c6656..315b30c97 100644 --- a/command/quota_init_test.go +++ b/command/quota_init_test.go @@ -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 diff --git a/command/quota_inspect_test.go b/command/quota_inspect_test.go index 79efc6bfc..3c7f7dde8 100644 --- a/command/quota_inspect_test.go +++ b/command/quota_inspect_test.go @@ -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 diff --git a/command/quota_list_test.go b/command/quota_list_test.go index 6909dcbe5..b1f21e8c2 100644 --- a/command/quota_list_test.go +++ b/command/quota_list_test.go @@ -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 diff --git a/command/quota_status_test.go b/command/quota_status_test.go index 5e71ab421..954d4cf70 100644 --- a/command/quota_status_test.go +++ b/command/quota_status_test.go @@ -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 diff --git a/command/server_members_test.go b/command/server_members_test.go index 08608eeb6..523b47932 100644 --- a/command/server_members_test.go +++ b/command/server_members_test.go @@ -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 diff --git a/command/status_test.go b/command/status_test.go index 4b7f1c38f..3cdf11fdd 100644 --- a/command/status_test.go +++ b/command/status_test.go @@ -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 diff --git a/command/system_gc_test.go b/command/system_gc_test.go index 89b11cfd2..e5d04ae6b 100644 --- a/command/system_gc_test.go +++ b/command/system_gc_test.go @@ -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 { diff --git a/command/system_reconcile_summaries_test.go b/command/system_reconcile_summaries_test.go index 3423f4eb6..ac478bf2f 100644 --- a/command/system_reconcile_summaries_test.go +++ b/command/system_reconcile_summaries_test.go @@ -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 { diff --git a/command/volume_status_test.go b/command/volume_status_test.go index a3c6a5b20..afd35213c 100644 --- a/command/volume_status_test.go +++ b/command/volume_status_test.go @@ -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()