Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: tests use new(cli.MockUi) which is strongly discouraged within lib #9026

Closed
jrasell opened this issue Oct 5, 2020 · 1 comment · Fixed by #9027
Closed

cli: tests use new(cli.MockUi) which is strongly discouraged within lib #9026

jrasell opened this issue Oct 5, 2020 · 1 comment · Fixed by #9027
Assignees
Labels

Comments

@jrasell
Copy link
Member

jrasell commented Oct 5, 2020

The command tests use the mockUI instantiated bynew(cli.MockUi), however, the library states this is incorrect and should be avoided.

// Do not instantite this
// directly since the buffers will be initialized on the first write. If
// there is no write then you will get a nil panic. Please use the
// NewMockUi() constructor function instead.

The Nomad tests (detailed below) should therefore be updated to avoid this behaviour.

 jrasell@pathfinder  ~/go/src/github.com/hashicorp/nomad   master  grep -r 'new(cli.MockUi)' .
./command/check_test.go:	ui := new(cli.MockUi)
./command/deployment_fail_test.go:	ui := new(cli.MockUi)
./command/deployment_fail_test.go:	ui := new(cli.MockUi)
./command/operator_snapshot_restore_test.go:		ui := new(cli.MockUi)
./command/operator_snapshot_restore_test.go:	ui := new(cli.MockUi)
./command/operator_snapshot_restore_test.go:	ui := new(cli.MockUi)
./command/alloc_exec_test.go:			ui := new(cli.MockUi)
./command/alloc_exec_test.go:		ui := new(cli.MockUi)
./command/alloc_exec_test.go:	ui := new(cli.MockUi)
./command/alloc_exec_test.go:	evalUi := new(cli.MockUi)
./command/alloc_exec_test.go:			ui := new(cli.MockUi)
./command/alloc_exec_test.go:			ui := new(cli.MockUi)
./command/namespace_inspect_test.go:	ui := new(cli.MockUi)
./command/namespace_inspect_test.go:	ui := new(cli.MockUi)
./command/namespace_inspect_test.go:	ui := new(cli.MockUi)
./command/namespace_inspect_test.go:	ui := new(cli.MockUi)
./command/acl_token_create_test.go:	ui := new(cli.MockUi)
./command/deployment_resume_test.go:	ui := new(cli.MockUi)
./command/deployment_resume_test.go:	ui := new(cli.MockUi)
./command/acl_policy_delete_test.go:	ui := new(cli.MockUi)
./command/job_init_test.go:	ui := new(cli.MockUi)
./command/job_init_test.go:	ui := new(cli.MockUi)
./command/namespace_status_test.go:	ui := new(cli.MockUi)
./command/namespace_status_test.go:	ui := new(cli.MockUi)
./command/namespace_status_test.go:	ui := new(cli.MockUi)
./command/namespace_status_test.go:	ui := new(cli.MockUi)
./command/namespace_status_test.go:	ui := new(cli.MockUi)
./command/node_status_test.go:	ui := new(cli.MockUi)
./command/node_status_test.go:	ui := new(cli.MockUi)
./command/node_status_test.go:	ui := new(cli.MockUi)
./command/node_status_test.go:	ui := new(cli.MockUi)
./command/quota_init_test.go:	ui := new(cli.MockUi)
./command/quota_init_test.go:	ui := new(cli.MockUi)
./command/operator_autopilot_set_test.go:	ui := new(cli.MockUi)
./command/job_run_test.go:	ui := new(cli.MockUi)
./command/job_run_test.go:	ui := new(cli.MockUi)
./command/job_run_test.go:	ui := new(cli.MockUi)
./command/job_run_test.go:	ui := new(cli.MockUi)
./command/job_promote_test.go:	ui := new(cli.MockUi)
./command/job_promote_test.go:	ui := new(cli.MockUi)
./command/job_deployments_test.go:	ui := new(cli.MockUi)
./command/job_deployments_test.go:	ui := new(cli.MockUi)
./command/job_deployments_test.go:	ui := new(cli.MockUi)
./command/job_deployments_test.go:	ui := new(cli.MockUi)
./command/deployment_status_test.go:	ui := new(cli.MockUi)
./command/deployment_status_test.go:	ui := new(cli.MockUi)
./command/alloc_logs_test.go:	ui := new(cli.MockUi)
./command/alloc_logs_test.go:	ui := new(cli.MockUi)
./command/node_eligibility_test.go:	ui := new(cli.MockUi)
./command/node_eligibility_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/status_test.go:	ui := new(cli.MockUi)
./command/namespace_list_test.go:	ui := new(cli.MockUi)
./command/namespace_list_test.go:	ui := new(cli.MockUi)
./command/quota_status_test.go:	ui := new(cli.MockUi)
./command/quota_status_test.go:	ui := new(cli.MockUi)
./command/quota_status_test.go:	ui := new(cli.MockUi)
./command/operator_snapshot_save_test.go:	ui := new(cli.MockUi)
./command/operator_snapshot_save_test.go:	ui := new(cli.MockUi)
./command/alloc_fs_test.go:	ui := new(cli.MockUi)
./command/alloc_fs_test.go:	ui := new(cli.MockUi)
./command/acl_token_info_test.go:	ui := new(cli.MockUi)
./command/agent/command_test.go:		ui := new(cli.MockUi)
./command/agent/command_test.go:		ui := new(cli.MockUi)
./command/acl_policy_list_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/alloc_status_test.go:	ui := new(cli.MockUi)
./command/quota_apply_test.go:	ui := new(cli.MockUi)
./command/operator_autopilot_get_test.go:	ui := new(cli.MockUi)
./command/acl_policy_info_test.go:	ui := new(cli.MockUi)
./command/monitor_test.go:	ui := new(cli.MockUi)
./command/monitor_test.go:	ui := new(cli.MockUi)
./command/monitor_test.go:	ui := new(cli.MockUi)
./command/monitor_test.go:	ui := new(cli.MockUi)
./command/monitor_test.go:	ui := new(cli.MockUi)
./command/acl_token_delete_test.go:	ui := new(cli.MockUi)
./command/agent_monitor_test.go:	ui := new(cli.MockUi)
./command/acl_bootstrap_test.go:	ui := new(cli.MockUi)
./command/acl_bootstrap_test.go:	ui := new(cli.MockUi)
./command/acl_bootstrap_test.go:	ui := new(cli.MockUi)
./command/acl_token_list_test.go:	ui := new(cli.MockUi)
./command/alloc_signal_test.go:	ui := new(cli.MockUi)
./command/alloc_signal_test.go:	ui := new(cli.MockUi)
./command/alloc_signal_test.go:	ui := new(cli.MockUi)
./command/quota_list_test.go:	ui := new(cli.MockUi)
./command/quota_list_test.go:	ui := new(cli.MockUi)
./command/license_put_test.go:	ui := new(cli.MockUi)
./command/alloc_restart_test.go:	ui := new(cli.MockUi)
./command/alloc_restart_test.go:	ui := new(cli.MockUi)
./command/alloc_restart_test.go:	ui := new(cli.MockUi)
./command/node_config_test.go:	ui := new(cli.MockUi)
./command/node_config_test.go:	ui := new(cli.MockUi)
./command/deployment_promote_test.go:	ui := new(cli.MockUi)
./command/deployment_promote_test.go:	ui := new(cli.MockUi)
./command/deployment_list_test.go:	ui := new(cli.MockUi)
./command/namespace_delete_test.go:	ui := new(cli.MockUi)
./command/namespace_delete_test.go:	ui := new(cli.MockUi)
./command/namespace_delete_test.go:	ui := new(cli.MockUi)
./command/operator_raft_remove_test.go:	ui := new(cli.MockUi)
./command/operator_raft_remove_test.go:	ui := new(cli.MockUi)
./command/operator_raft_remove_test.go:	ui := new(cli.MockUi)
./command/job_status_test.go:	ui := new(cli.MockUi)
./command/job_status_test.go:	ui := new(cli.MockUi)
./command/job_status_test.go:	ui := new(cli.MockUi)
./command/job_status_test.go:	ui := new(cli.MockUi)
./command/job_status_test.go:	ui := new(cli.MockUi)
./command/job_validate_test.go:	ui := new(cli.MockUi)
./command/job_validate_test.go:	ui := new(cli.MockUi)
./command/job_validate_test.go:	ui := new(cli.MockUi)
./command/job_validate_test.go:	ui := new(cli.MockUi)
./command/deployment_unblock_test.go:	ui := new(cli.MockUi)
./command/deployment_unblock_test.go:	ui := new(cli.MockUi)
./command/operator_debug_test.go:	ui := new(cli.MockUi)
./command/operator_debug_test.go:	ui := new(cli.MockUi)
./command/helpers_test.go:	meta := Meta{Ui: new(cli.MockUi)}
./command/job_revert_test.go:	ui := new(cli.MockUi)
./command/job_revert_test.go:	ui := new(cli.MockUi)
./command/job_stop_test.go:	ui := new(cli.MockUi)
./command/job_stop_test.go:	ui := new(cli.MockUi)
./command/server_members_test.go:	ui := new(cli.MockUi)
./command/server_members_test.go:	ui := new(cli.MockUi)
./command/server_members_test.go:	ui := new(cli.MockUi)
./command/acl_policy_apply_test.go:	ui := new(cli.MockUi)
./command/job_periodic_force_test.go:	ui := new(cli.MockUi)
./command/job_periodic_force_test.go:	ui := new(cli.MockUi)
./command/job_periodic_force_test.go:	ui := new(cli.MockUi)
./command/job_periodic_force_test.go:	ui := new(cli.MockUi)
./command/job_periodic_force_test.go:	ui := new(cli.MockUi)
./command/job_history_test.go:	ui := new(cli.MockUi)
./command/job_history_test.go:	ui := new(cli.MockUi)
./command/namespace_apply_test.go:	ui := new(cli.MockUi)
./command/namespace_apply_test.go:	ui := new(cli.MockUi)
./command/operator_keygen_test.go:	ui := new(cli.MockUi)
./command/acl_token_update_test.go:	ui := new(cli.MockUi)
./command/job_eval_test.go:	ui := new(cli.MockUi)
./command/job_eval_test.go:	ui := new(cli.MockUi)
./command/job_eval_test.go:	ui := new(cli.MockUi)
./command/acl_token_self_test.go:	ui := new(cli.MockUi)
./command/alloc_stop_test.go:	ui := new(cli.MockUi)
./command/alloc_stop_test.go:	ui := new(cli.MockUi)
./command/quota_inspect_test.go:	ui := new(cli.MockUi)
./command/quota_inspect_test.go:	ui := new(cli.MockUi)
./command/quota_inspect_test.go:	ui := new(cli.MockUi)
./command/system_reconcile_summaries_test.go:	ui := new(cli.MockUi)
./command/volume_status_test.go:	ui := new(cli.MockUi)
./command/volume_status_test.go:	ui := new(cli.MockUi)
./command/node_drain_test.go:	ui := new(cli.MockUi)
./command/node_drain_test.go:	ui := new(cli.MockUi)
./command/node_drain_test.go:	ui := new(cli.MockUi)
./command/job_inspect_test.go:	ui := new(cli.MockUi)
./command/job_inspect_test.go:	ui := new(cli.MockUi)
./command/license_get_test.go:	ui := new(cli.MockUi)
./command/license_get_test.go:	ui := new(cli.MockUi)
./command/system_gc_test.go:	ui := new(cli.MockUi)
./command/job_dispatch_test.go:	ui := new(cli.MockUi)
./command/job_dispatch_test.go:	ui := new(cli.MockUi)
./command/deployment_pause_test.go:	ui := new(cli.MockUi)
./command/deployment_pause_test.go:	ui := new(cli.MockUi)
./command/eval_status_test.go:	ui := new(cli.MockUi)
./command/eval_status_test.go:	ui := new(cli.MockUi)
./command/quota_delete_test.go:	ui := new(cli.MockUi)
./command/quota_delete_test.go:	ui := new(cli.MockUi)
./command/quota_delete_test.go:	ui := new(cli.MockUi)
./command/operator_snapshot_inspect_test.go:	ui := new(cli.MockUi)
./command/operator_snapshot_inspect_test.go:		ui := new(cli.MockUi)
./command/operator_snapshot_inspect_test.go:		ui := new(cli.MockUi)
./command/operator_snapshot_inspect_test.go:	ui := new(cli.MockUi)
./command/plugin_status_test.go:	ui := new(cli.MockUi)
./command/plugin_status_test.go:	ui := new(cli.MockUi)
./command/operator_raft_list_test.go:	ui := new(cli.MockUi)
./command/agent_info_test.go:	ui := new(cli.MockUi)
./command/agent_info_test.go:	ui := new(cli.MockUi)
./command/job_plan_test.go:	ui := new(cli.MockUi)
./command/job_plan_test.go:	ui := new(cli.MockUi)
./command/job_plan_test.go:	ui := new(cli.MockUi)
./command/job_plan_test.go:	ui := new(cli.MockUi)
@github-actions
Copy link

github-actions bot commented Nov 1, 2022

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant