From 40ecb8c18825297871310dd9ce9304474a23d26f Mon Sep 17 00:00:00 2001 From: vilmibm Date: Tue, 26 Jul 2022 16:06:52 -0500 Subject: [PATCH] update linter checks --- pkg/cmd/auth/logout/logout_test.go | 1 + pkg/cmd/auth/refresh/refresh_test.go | 1 + pkg/cmd/gist/edit/edit_test.go | 4 ++ pkg/cmd/gist/view/view_test.go | 3 ++ pkg/cmd/issue/create/create_test.go | 8 ++++ pkg/cmd/issue/delete/delete_test.go | 2 + pkg/cmd/label/delete_test.go | 1 + pkg/cmd/pr/create/create_test.go | 30 ++++++++---- pkg/cmd/pr/merge/merge_test.go | 19 ++++++++ pkg/cmd/pr/shared/survey_test.go | 12 ++--- pkg/cmd/pr/shared/templates_test.go | 2 + pkg/cmd/release/create/create_test.go | 27 +++++++++++ pkg/cmd/repo/archive/archive_test.go | 6 +-- pkg/cmd/repo/create/create_test.go | 60 ++++++++++++------------ pkg/cmd/repo/edit/edit_test.go | 10 ++++ pkg/cmd/repo/fork/fork_test.go | 12 ++--- pkg/cmd/repo/rename/rename_test.go | 10 ++-- pkg/cmd/run/cancel/cancel_test.go | 4 +- pkg/cmd/run/rerun/rerun_test.go | 4 +- pkg/cmd/run/view/view_test.go | 28 +++++------ pkg/cmd/run/watch/watch_test.go | 2 + pkg/cmd/secret/set/set_test.go | 1 + pkg/cmd/workflow/disable/disable_test.go | 2 + pkg/cmd/workflow/enable/enable_test.go | 2 + pkg/cmd/workflow/run/run_test.go | 4 ++ pkg/prompt/stubber.go | 11 +++-- 26 files changed, 187 insertions(+), 79 deletions(-) diff --git a/pkg/cmd/auth/logout/logout_test.go b/pkg/cmd/auth/logout/logout_test.go index aa176f9f0..7ccb4bd48 100644 --- a/pkg/cmd/auth/logout/logout_test.go +++ b/pkg/cmd/auth/logout/logout_test.go @@ -106,6 +106,7 @@ func Test_logoutRun_tty(t *testing.T) { cfgHosts: []string{"cheryl.mason", "github.com"}, wantHosts: "cheryl.mason:\n oauth_token: abc123\n", askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What account do you want to log out of?").AnswerWith("github.com") }, wantErrOut: regexp.MustCompile(`Logged out of github.com account 'cybilb'`), diff --git a/pkg/cmd/auth/refresh/refresh_test.go b/pkg/cmd/auth/refresh/refresh_test.go index 3de01897f..7267ced0f 100644 --- a/pkg/cmd/auth/refresh/refresh_test.go +++ b/pkg/cmd/auth/refresh/refresh_test.go @@ -194,6 +194,7 @@ func Test_refreshRun(t *testing.T) { Hostname: "", }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What account do you want to refresh auth for?").AnswerWith("github.com") }, wantAuthArgs: authArgs{ diff --git a/pkg/cmd/gist/edit/edit_test.go b/pkg/cmd/gist/edit/edit_test.go index 7318f26f8..0957ebddb 100644 --- a/pkg/cmd/gist/edit/edit_test.go +++ b/pkg/cmd/gist/edit/edit_test.go @@ -162,7 +162,9 @@ func Test_editRun(t *testing.T) { { name: "multiple files, submit", askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Edit which file?").AnswerWith("unix.md") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What next?").AnswerWith("Submit") }, gist: &shared.Gist{ @@ -207,7 +209,9 @@ func Test_editRun(t *testing.T) { { name: "multiple files, cancel", askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Edit which file?").AnswerWith("unix.md") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What next?").AnswerWith("Cancel") }, wantErr: "CancelError", diff --git a/pkg/cmd/gist/view/view_test.go b/pkg/cmd/gist/view/view_test.go index 42ec91fef..58fb1ee7f 100644 --- a/pkg/cmd/gist/view/view_test.go +++ b/pkg/cmd/gist/view/view_test.go @@ -356,6 +356,7 @@ func Test_viewRun(t *testing.T) { ) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a gist").AnswerDefault() } @@ -401,6 +402,7 @@ func Test_promptGists(t *testing.T) { { name: "multiple files, select first gist", askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a gist").AnswerWith("cool.txt about 6 hours ago") }, response: `{ "data": { "viewer": { "gists": { "nodes": [ @@ -424,6 +426,7 @@ func Test_promptGists(t *testing.T) { { name: "multiple files, select second gist", askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a gist").AnswerWith("gistfile0.txt about 6 hours ago") }, response: `{ "data": { "viewer": { "gists": { "nodes": [ diff --git a/pkg/cmd/issue/create/create_test.go b/pkg/cmd/issue/create/create_test.go index ae98535c5..b2ebbd69b 100644 --- a/pkg/cmd/issue/create/create_test.go +++ b/pkg/cmd/issue/create/create_test.go @@ -404,8 +404,11 @@ func TestIssueCreate_recover(t *testing.T) { as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Body").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Submit") tmpfile, err := os.CreateTemp(t.TempDir(), "testrecover*") @@ -471,8 +474,11 @@ func TestIssueCreate_nonLegacyTemplate(t *testing.T) { as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a template").AnswerWith("Submit a request") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Body").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?"). AssertOptions([]string{"Submit", "Continue in browser", "Cancel"}). AnswerWith("Submit") @@ -501,7 +507,9 @@ func TestIssueCreate_continueInBrowser(t *testing.T) { as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title").AnswerWith("hello") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Continue in browser") _, cmdTeardown := run.Stub() diff --git a/pkg/cmd/issue/delete/delete_test.go b/pkg/cmd/issue/delete/delete_test.go index 2cf323e56..2a2837c47 100644 --- a/pkg/cmd/issue/delete/delete_test.go +++ b/pkg/cmd/issue/delete/delete_test.go @@ -77,6 +77,7 @@ func TestIssueDelete(t *testing.T) { ) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("You're going to delete issue #13. This action cannot be reversed. To confirm, type the issue number:").AnswerWith("13") output, err := runCommand(httpRegistry, true, "13") @@ -137,6 +138,7 @@ func TestIssueDelete_cancel(t *testing.T) { ) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("You're going to delete issue #13. This action cannot be reversed. To confirm, type the issue number:").AnswerWith("14") output, err := runCommand(httpRegistry, true, "13") diff --git a/pkg/cmd/label/delete_test.go b/pkg/cmd/label/delete_test.go index 48fba81c5..918e12c76 100644 --- a/pkg/cmd/label/delete_test.go +++ b/pkg/cmd/label/delete_test.go @@ -105,6 +105,7 @@ func TestDeleteRun(t *testing.T) { askStubs: func(as *prompt.AskStubber) { // TODO: survey stubber doesn't have WithValidator support // so this always passes regardless of prompt input + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Type test to confirm deletion:").AnswerWith("test") }, wantStdout: "✓ Label \"test\" deleted from OWNER/REPO\n", diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index 33feafa40..e4710d546 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -311,12 +311,15 @@ func TestPRCreate_recover(t *testing.T) { cs.Register(`git status --porcelain`, 0, "") cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "") - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, teardown := prompt.InitAskStubber() defer teardown() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Body").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerDefault() tmpfile, err := os.CreateTemp(t.TempDir(), "testrecover*") @@ -409,10 +412,11 @@ func TestPRCreate(t *testing.T) { cs.Register(`git show-ref --verify -- HEAD refs/remotes/origin/feature`, 0, "") cs.Register(`git push --set-upstream origin HEAD:feature`, 0, "") - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock ask.StubPrompt("Where should we push the 'feature' branch?").AnswerDefault() output, err := runCommand(http, nil, "feature", true, `-t "my title" -b "my body"`) @@ -456,10 +460,11 @@ func TestPRCreate_NoMaintainerModify(t *testing.T) { cs.Register(`git show-ref --verify -- HEAD refs/remotes/origin/feature`, 0, "") cs.Register(`git push --set-upstream origin HEAD:feature`, 0, "") - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock ask.StubPrompt("Where should we push the 'feature' branch?").AnswerDefault() output, err := runCommand(http, nil, "feature", true, `-t "my title" -b "my body" --no-maintainer-edit`) @@ -508,10 +513,11 @@ func TestPRCreate_createFork(t *testing.T) { cs.Register(`git remote add -f fork https://github.com/monalisa/REPO.git`, 0, "") cs.Register(`git push --set-upstream fork HEAD:feature`, 0, "") - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock ask.StubPrompt("Where should we push the 'feature' branch?"). AssertOptions([]string{"OWNER/REPO", "Create a fork of OWNER/REPO", "Skip pushing the branch", "Cancel"}). AnswerWith("Create a fork of OWNER/REPO") @@ -568,7 +574,7 @@ func TestPRCreate_pushedToNonBaseRepo(t *testing.T) { deadbeef refs/remotes/origin/feature `)) // determineTrackingBranch - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock _, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() @@ -610,7 +616,7 @@ func TestPRCreate_pushedToDifferentBranchName(t *testing.T) { deadbeef refs/remotes/origin/my-feat2 `)) // determineTrackingBranch - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock _, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() @@ -656,10 +662,13 @@ func TestPRCreate_nonLegacyTemplate(t *testing.T) { as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a template"). AssertOptions([]string{"template1", "template2", "Open a blank pull request"}). AnswerWith("template1") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Body").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?"). AssertOptions([]string{"Submit", "Submit as draft", "Continue in browser", "Add metadata", "Cancel"}). AnswerDefault() @@ -801,10 +810,11 @@ func TestPRCreate_web(t *testing.T) { cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "") cs.Register(`git push --set-upstream origin HEAD:feature`, 0, "") - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock ask.StubPrompt("Where should we push the 'feature' branch?"). AssertOptions([]string{"OWNER/REPO", "Skip pushing the branch", "Cancel"}). AnswerDefault() @@ -876,10 +886,11 @@ func TestPRCreate_webProject(t *testing.T) { cs.Register(`git( .+)? log( .+)? origin/master\.\.\.feature`, 0, "") cs.Register(`git push --set-upstream origin HEAD:feature`, 0, "") - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock ask, cleanupAsk := prompt.InitAskStubber() defer cleanupAsk() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock ask.StubPrompt("Where should we push the 'feature' branch?").AnswerDefault() output, err := runCommand(http, nil, "feature", true, `--web -p Triage`) @@ -918,8 +929,11 @@ func TestPRCreate_draft(t *testing.T) { as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a template").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Body").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?"). AssertOptions([]string{"Submit", "Submit as draft", "Continue in browser", "Add metadata", "Cancel"}). AnswerWith("Submit as draft") diff --git a/pkg/cmd/pr/merge/merge_test.go b/pkg/cmd/pr/merge/merge_test.go index 4afa03ab4..591cf450c 100644 --- a/pkg/cmd/pr/merge/merge_test.go +++ b/pkg/cmd/pr/merge/merge_test.go @@ -961,6 +961,7 @@ func TestPrMerge_alreadyMerged(t *testing.T) { cs.Register(`git pull --ff-only`, 0, "") as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Pull request #4 was already merged. Delete the branch locally?").AnswerWith(true) output, err := runCommand(http, "blueberries", true, "pr merge 4") @@ -1022,6 +1023,7 @@ func TestPrMerge_alreadyMerged_withMergeStrategy_TTY(t *testing.T) { cs.Register(`git branch -D `, 0, "") as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Pull request #4 was already merged. Delete the branch locally?").AnswerWith(true) output, err := runCommand(http, "blueberries", true, "pr merge 4 --merge") @@ -1101,8 +1103,11 @@ func TestPRMergeTTY(t *testing.T) { cs.Register(`git rev-parse --verify refs/heads/blueberries`, 0, "") as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What merge method would you like to use?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Delete the branch locally and on GitHub?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Submit") output, err := runCommand(http, "blueberries", true, "") @@ -1162,7 +1167,9 @@ func TestPRMergeTTY_withDeleteBranch(t *testing.T) { cs.Register(`git pull --ff-only`, 0, "") as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What merge method would you like to use?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Submit") output, err := runCommand(http, "blueberries", true, "-d") @@ -1221,10 +1228,15 @@ func TestPRMergeTTY_squashEditCommitMsgAndSubject(t *testing.T) { defer cmdTeardown(t) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What merge method would you like to use?").AnswerWith("Squash and merge") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Delete the branch on GitHub?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Edit commit message") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Edit commit subject") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Submit") err := mergeRun(&MergeOptions{ @@ -1299,8 +1311,11 @@ func TestPRTTY_cancelled(t *testing.T) { cs.Register(`git rev-parse --verify refs/heads/`, 0, "") as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What merge method would you like to use?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Delete the branch locally and on GitHub?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerWith("Cancel") output, err := runCommand(http, "blueberries", true, "") @@ -1318,6 +1333,7 @@ func Test_mergeMethodSurvey(t *testing.T) { SquashMergeAllowed: true, } as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What merge method would you like to use?").AnswerWith("Rebase and merge") method, err := mergeMethodSurvey(repo) @@ -1625,8 +1641,11 @@ func TestPrAddToMergeQueueAdmin(t *testing.T) { cs.Register(`git rev-parse --verify refs/heads/`, 0, "") as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What merge method would you like to use?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Delete the branch locally and on GitHub?").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What's next?").AnswerDefault() output, err := runCommand(http, "blueberries", true, "pr merge 1 --admin") diff --git a/pkg/cmd/pr/shared/survey_test.go b/pkg/cmd/pr/shared/survey_test.go index 0bc27e8d6..d25858435 100644 --- a/pkg/cmd/pr/shared/survey_test.go +++ b/pkg/cmd/pr/shared/survey_test.go @@ -43,18 +43,18 @@ func TestMetadataSurvey_selectAll(t *testing.T) { }, } - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, restoreAsk := prompt.InitAskStubber() defer restoreAsk() - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ { Name: "metadata", Value: []string{"Labels", "Projects", "Assignees", "Reviewers", "Milestone"}, }, }) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ { Name: "reviewers", @@ -112,18 +112,18 @@ func TestMetadataSurvey_keepExisting(t *testing.T) { }, } - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, restoreAsk := prompt.InitAskStubber() defer restoreAsk() - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ { Name: "metadata", Value: []string{"Labels", "Projects"}, }, }) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ { Name: "labels", diff --git a/pkg/cmd/pr/shared/templates_test.go b/pkg/cmd/pr/shared/templates_test.go index 752de47c1..12335b61a 100644 --- a/pkg/cmd/pr/shared/templates_test.go +++ b/pkg/cmd/pr/shared/templates_test.go @@ -48,6 +48,7 @@ func TestTemplateManager_hasAPI(t *testing.T) { assert.Equal(t, "LEGACY", string(m.LegacyBody())) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a template"). AssertOptions([]string{"Bug report", "Feature request", "Open a blank issue"}). AnswerWith("Feature request") @@ -94,6 +95,7 @@ func TestTemplateManager_hasAPI_PullRequest(t *testing.T) { assert.Equal(t, "LEGACY", string(m.LegacyBody())) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a template"). AssertOptions([]string{"bug_pr.md", "feature_pr.md", "Open a blank pull request"}). AnswerWith("bug_pr.md") diff --git a/pkg/cmd/release/create/create_test.go b/pkg/cmd/release/create/create_test.go index b4a95e1e6..c3ab9cdd3 100644 --- a/pkg/cmd/release/create/create_test.go +++ b/pkg/cmd/release/create/create_test.go @@ -597,14 +597,19 @@ func Test_createRun_interactive(t *testing.T) { name: "create a release from existing tag", opts: &CreateOptions{}, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a tag"). AssertOptions([]string{"v1.2.3", "v1.2.2", "v1.0.0", "v0.1.2", "Create a new tag"}). AnswerWith("v1.2.3") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title (optional)").AnswerWith("") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Release notes"). AssertOptions([]string{"Write my own", "Write using generated notes as template", "Leave blank"}). AnswerWith("Leave blank") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Is this a prerelease?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Submit?"). AssertOptions([]string{"Publish release", "Save as draft", "Cancel"}).AnswerWith("Publish release") }, @@ -632,13 +637,19 @@ func Test_createRun_interactive(t *testing.T) { name: "create a release from new tag", opts: &CreateOptions{}, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Choose a tag").AnswerWith("Create a new tag") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Tag name").AnswerWith("v1.2.3") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title (optional)").AnswerWith("") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Release notes"). AssertOptions([]string{"Write my own", "Write using generated notes as template", "Leave blank"}). AnswerWith("Leave blank") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Is this a prerelease?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Submit?").AnswerWith("Publish release") }, runStubs: func(rs *run.CommandStubber) { @@ -667,11 +678,15 @@ func Test_createRun_interactive(t *testing.T) { TagName: "v1.2.3", }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title (optional)").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Release notes"). AssertOptions([]string{"Write my own", "Write using generated notes as template", "Leave blank"}). AnswerWith("Write using generated notes as template") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Is this a prerelease?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Submit?").AnswerWith("Publish release") }, runStubs: func(rs *run.CommandStubber) { @@ -705,11 +720,15 @@ func Test_createRun_interactive(t *testing.T) { TagName: "v1.2.3", }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title (optional)").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Release notes"). AssertOptions([]string{"Write my own", "Write using commit log as template", "Leave blank"}). AnswerWith("Write using commit log as template") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Is this a prerelease?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Submit?").AnswerWith("Publish release") }, runStubs: func(rs *run.CommandStubber) { @@ -741,11 +760,15 @@ func Test_createRun_interactive(t *testing.T) { TagName: "v1.2.3", }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title (optional)").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Release notes"). AssertOptions([]string{"Write my own", "Write using git tag message as template", "Leave blank"}). AnswerWith("Write using git tag message as template") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Is this a prerelease?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Submit?").AnswerWith("Publish release") }, runStubs: func(rs *run.CommandStubber) { @@ -793,11 +816,15 @@ func Test_createRun_interactive(t *testing.T) { Target: "main", }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Title (optional)").AnswerWith("") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Release notes"). AssertOptions([]string{"Write my own", "Write using generated notes as template", "Write using git tag message as template", "Leave blank"}). AnswerWith("Leave blank") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Is this a prerelease?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Submit?").AnswerWith("Publish release") }, runStubs: func(rs *run.CommandStubber) { diff --git a/pkg/cmd/repo/archive/archive_test.go b/pkg/cmd/repo/archive/archive_test.go index 6d681e784..788ec2a8f 100644 --- a/pkg/cmd/repo/archive/archive_test.go +++ b/pkg/cmd/repo/archive/archive_test.go @@ -80,7 +80,7 @@ func Test_ArchiveRun(t *testing.T) { name: "unarchived repo tty", wantStdout: "✓ Archived repository OWNER/REPO\n", askStubs: func(q *prompt.AskStubber) { - //nolint:staticcheck // SA1019: q.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: q.StubOne is deprecated: use PrompterMock q.StubOne(true) }, isTTY: true, @@ -99,7 +99,7 @@ func Test_ArchiveRun(t *testing.T) { wantStdout: "✓ Archived repository OWNER/REPO\n", opts: ArchiveOptions{}, askStubs: func(q *prompt.AskStubber) { - //nolint:staticcheck // SA1019: q.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: q.StubOne is deprecated: use PrompterMock q.StubOne(true) }, isTTY: true, @@ -140,7 +140,7 @@ func Test_ArchiveRun(t *testing.T) { ios, _, stdout, stderr := iostreams.Test() tt.opts.IO = ios - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock q, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/repo/create/create_test.go b/pkg/cmd/repo/create/create_test.go index 75dd3a0d1..074f0b2df 100644 --- a/pkg/cmd/repo/create/create_test.go +++ b/pkg/cmd/repo/create/create_test.go @@ -187,30 +187,30 @@ func Test_createRun(t *testing.T) { tty: true, wantStdout: "✓ Created repository OWNER/REPO on GitHub\n", askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("Create a new repository on GitHub from scratch") - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "repoName", Value: "REPO"}, {Name: "repoDescription", Value: "my new repo"}, {Name: "repoVisibility", Value: "Private"}, }) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "addGitIgnore", Value: true}}) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "chooseGitIgnore", Value: "Go"}}) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "addLicense", Value: true}}) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "chooseLicense", Value: "GNU Lesser General Public License v3.0"}}) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "confirmSubmit", Value: true}}) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) //clone locally? }, httpStubs: func(reg *httpmock.Registry) { @@ -234,21 +234,21 @@ func Test_createRun(t *testing.T) { opts: &CreateOptions{Interactive: true}, tty: true, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("Create a new repository on GitHub from scratch") - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "repoName", Value: "REPO"}, {Name: "repoDescription", Value: "my new repo"}, {Name: "repoVisibility", Value: "Private"}, }) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "addGitIgnore", Value: false}}) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "addLicense", Value: false}}) - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "confirmSubmit", Value: false}}) }, @@ -261,17 +261,17 @@ func Test_createRun(t *testing.T) { opts: &CreateOptions{Interactive: true}, tty: true, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("Push an existing local repository to GitHub") - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(".") - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "repoName", Value: "REPO"}, {Name: "repoDescription", Value: "my new repo"}, {Name: "repoVisibility", Value: "Private"}, }) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(false) }, httpStubs: func(reg *httpmock.Registry) { @@ -302,21 +302,21 @@ func Test_createRun(t *testing.T) { opts: &CreateOptions{Interactive: true}, tty: true, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("Push an existing local repository to GitHub") - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(".") - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "repoName", Value: "REPO"}, {Name: "repoDescription", Value: "my new repo"}, {Name: "repoVisibility", Value: "Private"}, }) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) //ask for adding a remote - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("origin") //ask for remote name - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(false) //ask to push to remote }, httpStubs: func(reg *httpmock.Registry) { @@ -348,21 +348,21 @@ func Test_createRun(t *testing.T) { opts: &CreateOptions{Interactive: true}, tty: true, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("Push an existing local repository to GitHub") - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(".") - //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.Stub is deprecated; use PrompterMock as.Stub([]*prompt.QuestionStub{ {Name: "repoName", Value: "REPO"}, {Name: "repoDescription", Value: "my new repo"}, {Name: "repoVisibility", Value: "Private"}, }) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) //ask for adding a remote - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne("origin") //ask for remote name - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) //ask to push to remote }, httpStubs: func(reg *httpmock.Registry) { @@ -452,7 +452,7 @@ func Test_createRun(t *testing.T) { }, } for _, tt := range tests { - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock q, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/repo/edit/edit_test.go b/pkg/cmd/repo/edit/edit_test.go index dc4198581..769846972 100644 --- a/pkg/cmd/repo/edit/edit_test.go +++ b/pkg/cmd/repo/edit/edit_test.go @@ -173,7 +173,9 @@ func Test_editRun_interactive(t *testing.T) { InteractiveMode: true, }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What do you want to edit?").AnswerWith([]string{"Description"}) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Description of the repository").AnswerWith("awesome repo description") }, httpStubs: func(t *testing.T, reg *httpmock.Registry) { @@ -213,9 +215,13 @@ func Test_editRun_interactive(t *testing.T) { InteractiveMode: true, }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What do you want to edit?").AnswerWith([]string{"Description", "Topics"}) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Description of the repository").AnswerWith("awesome repo description") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Add topics?(csv format)").AnswerWith("a, b,c,d ") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Remove Topics").AnswerWith([]string{"x"}) }, httpStubs: func(t *testing.T, reg *httpmock.Registry) { @@ -260,9 +266,13 @@ func Test_editRun_interactive(t *testing.T) { InteractiveMode: true, }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("What do you want to edit?").AnswerWith([]string{"Merge Options"}) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Allowed merge strategies").AnswerWith([]string{allowMergeCommits, allowRebaseMerge}) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Enable Auto Merge?").AnswerWith(false) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Automatically delete head branches after merging?").AnswerWith(false) }, httpStubs: func(t *testing.T, reg *httpmock.Registry) { diff --git a/pkg/cmd/repo/fork/fork_test.go b/pkg/cmd/repo/fork/fork_test.go index 111eb98f6..c395190a6 100644 --- a/pkg/cmd/repo/fork/fork_test.go +++ b/pkg/cmd/repo/fork/fork_test.go @@ -272,7 +272,7 @@ func TestRepoFork(t *testing.T) { }, httpStubs: forkPost, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(false) }, wantErrOut: "✓ Created fork someone/REPO\n", @@ -291,7 +291,7 @@ func TestRepoFork(t *testing.T) { cs.Register(`git remote add -f origin https://github.com/someone/REPO.git`, 0, "") }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) }, wantErrOut: "✓ Created fork someone/REPO\n✓ Added remote origin\n", @@ -494,7 +494,7 @@ func TestRepoFork(t *testing.T) { }, httpStubs: forkPost, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(false) }, wantErrOut: "✓ Created fork someone/REPO\n", @@ -508,7 +508,7 @@ func TestRepoFork(t *testing.T) { }, httpStubs: forkPost, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) }, execStubs: func(cs *run.CommandStubber) { @@ -529,7 +529,7 @@ func TestRepoFork(t *testing.T) { }, httpStubs: forkPost, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(true) }, execStubs: func(cs *run.CommandStubber) { @@ -700,7 +700,7 @@ func TestRepoFork(t *testing.T) { return tt.remotes, nil } - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/repo/rename/rename_test.go b/pkg/cmd/repo/rename/rename_test.go index 97e1aebb7..f536f2ab0 100644 --- a/pkg/cmd/repo/rename/rename_test.go +++ b/pkg/cmd/repo/rename/rename_test.go @@ -117,7 +117,7 @@ func TestRenameRun(t *testing.T) { name: "none argument", wantOut: "✓ Renamed repository OWNER/NEW_REPO\n✓ Updated the \"origin\" remote\n", askStubs: func(q *prompt.AskStubber) { - //nolint:staticcheck // SA1019: q.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: q.StubOne is deprecated: use PrompterMock q.StubOne("NEW_REPO") }, httpStubs: func(reg *httpmock.Registry) { @@ -137,7 +137,7 @@ func TestRenameRun(t *testing.T) { }, wantOut: "✓ Renamed repository OWNER/NEW_REPO\n", askStubs: func(q *prompt.AskStubber) { - //nolint:staticcheck // SA1019: q.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: q.StubOne is deprecated: use PrompterMock q.StubOne("NEW_REPO") }, httpStubs: func(reg *httpmock.Registry) { @@ -186,7 +186,7 @@ func TestRenameRun(t *testing.T) { }, wantOut: "✓ Renamed repository OWNER/NEW_REPO\n✓ Updated the \"origin\" remote\n", askStubs: func(q *prompt.AskStubber) { - //nolint:staticcheck // SA1019: q.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: q.StubOne is deprecated: use PrompterMock q.StubOne(true) }, httpStubs: func(reg *httpmock.Registry) { @@ -207,7 +207,7 @@ func TestRenameRun(t *testing.T) { DoConfirm: true, }, askStubs: func(q *prompt.AskStubber) { - //nolint:staticcheck // SA1019: q.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: q.StubOne is deprecated: use PrompterMock q.StubOne(false) }, wantOut: "", @@ -215,7 +215,7 @@ func TestRenameRun(t *testing.T) { } for _, tt := range testCases { - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock q, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/run/cancel/cancel_test.go b/pkg/cmd/run/cancel/cancel_test.go index 4875918d7..a66e58552 100644 --- a/pkg/cmd/run/cancel/cancel_test.go +++ b/pkg/cmd/run/cancel/cancel_test.go @@ -174,7 +174,7 @@ func TestRunCancel(t *testing.T) { httpmock.StatusStringResponse(202, "{}")) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(0) }, wantOut: "✓ Request to cancel workflow submitted.\n", @@ -196,7 +196,7 @@ func TestRunCancel(t *testing.T) { return ghrepo.FromFullName("OWNER/REPO") } - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/run/rerun/rerun_test.go b/pkg/cmd/run/rerun/rerun_test.go index 5d9dd3dc0..0bce30edb 100644 --- a/pkg/cmd/run/rerun/rerun_test.go +++ b/pkg/cmd/run/rerun/rerun_test.go @@ -294,7 +294,7 @@ func TestRerun(t *testing.T) { httpmock.StringResponse("{}")) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) }, wantOut: "✓ Requested rerun of run 1234\n", @@ -351,7 +351,7 @@ func TestRerun(t *testing.T) { return ghrepo.FromFullName("OWNER/REPO") } - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/run/view/view_test.go b/pkg/cmd/run/view/view_test.go index c2a9e51c9..b61f9ec35 100644 --- a/pkg/cmd/run/view/view_test.go +++ b/pkg/cmd/run/view/view_test.go @@ -374,7 +374,7 @@ func TestViewRun(t *testing.T) { httpmock.JSONResponse([]shared.Annotation{})) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) }, opts: &ViewOptions{ @@ -411,9 +411,9 @@ func TestViewRun(t *testing.T) { httpmock.FileResponse("./fixtures/run_log.zip")) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(1) }, wantOut: coolJobRunLogOutput, @@ -466,9 +466,9 @@ func TestViewRun(t *testing.T) { httpmock.FileResponse("./fixtures/run_log.zip")) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(0) }, wantOut: expectedRunLogOutput, @@ -527,9 +527,9 @@ func TestViewRun(t *testing.T) { httpmock.FileResponse("./fixtures/run_log.zip")) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(4) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) }, wantOut: quuxTheBarfLogOutput, @@ -582,9 +582,9 @@ func TestViewRun(t *testing.T) { httpmock.FileResponse("./fixtures/run_log.zip")) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(4) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(0) }, wantOut: quuxTheBarfLogOutput, @@ -708,9 +708,9 @@ func TestViewRun(t *testing.T) { httpmock.JSONResponse(shared.FailedJobAnnotations)) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(0) }, wantOut: "\n✓ trunk successful · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\nX sad job in 4m34s (ID 20)\n ✓ barf the quux\n X quux the barf\n\nANNOTATIONS\nX the job is sad\nsad job: blaze.py#420\n\n\nFor more information about a job, try: gh run view --job=\nView this run on GitHub: https://github.com/runs/3\n", @@ -743,9 +743,9 @@ func TestViewRun(t *testing.T) { httpmock.JSONResponse([]shared.Annotation{})) }, askStubs: func(as *prompt.AskStubber) { - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(2) - //nolint:staticcheck // SA1019: as.StubOne is deprecated: use StubPrompt + //nolint:staticcheck // SA1019: as.StubOne is deprecated; use PrompterMock as.StubOne(1) }, wantOut: "\n✓ trunk successful · 3\nTriggered via push about 59 minutes ago\n\n✓ cool job in 4m34s (ID 10)\n ✓ fob the barz\n ✓ barz the fob\n\nTo see the full job log, try: gh run view --log --job=10\nView this run on GitHub: https://github.com/runs/3\n", @@ -842,7 +842,7 @@ func TestViewRun(t *testing.T) { return ghrepo.FromFullName("OWNER/REPO") } - //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber + //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use PrompterMock as, teardown := prompt.InitAskStubber() defer teardown() if tt.askStubs != nil { diff --git a/pkg/cmd/run/watch/watch_test.go b/pkg/cmd/run/watch/watch_test.go index bdb08a58d..80105c48d 100644 --- a/pkg/cmd/run/watch/watch_test.go +++ b/pkg/cmd/run/watch/watch_test.go @@ -230,6 +230,7 @@ func TestWatchRun(t *testing.T) { }, httpStubs: successfulRunStubs, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a workflow run"). AssertOptions([]string{"* cool commit, run (trunk) Feb 23, 2021", "* cool commit, more runs (trunk) Feb 23, 2021"}). AnswerWith("* cool commit, more runs (trunk) Feb 23, 2021") @@ -246,6 +247,7 @@ func TestWatchRun(t *testing.T) { }, httpStubs: failedRunStubs, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a workflow run"). AssertOptions([]string{"* cool commit, run (trunk) Feb 23, 2021", "* cool commit, more runs (trunk) Feb 23, 2021"}). AnswerWith("* cool commit, more runs (trunk) Feb 23, 2021") diff --git a/pkg/cmd/secret/set/set_test.go b/pkg/cmd/secret/set/set_test.go index c9843a5a9..976ef4593 100644 --- a/pkg/cmd/secret/set/set_test.go +++ b/pkg/cmd/secret/set/set_test.go @@ -561,6 +561,7 @@ func Test_getBodyPrompt(t *testing.T) { ios.SetStdoutTTY(true) as := prompt.NewAskStubber(t) + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Paste your secret").AnswerWith("cool secret") body, err := getBody(&SetOptions{ diff --git a/pkg/cmd/workflow/disable/disable_test.go b/pkg/cmd/workflow/disable/disable_test.go index bc46212ed..2397b2f80 100644 --- a/pkg/cmd/workflow/disable/disable_test.go +++ b/pkg/cmd/workflow/disable/disable_test.go @@ -121,6 +121,7 @@ func TestDisableRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a workflow").AnswerWith("another workflow (another.yml)") }, wantOut: "✓ Disabled another workflow\n", @@ -176,6 +177,7 @@ func TestDisableRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Which workflow do you mean?").AnswerWith("another workflow (yetanother.yml)") }, wantOut: "✓ Disabled another workflow\n", diff --git a/pkg/cmd/workflow/enable/enable_test.go b/pkg/cmd/workflow/enable/enable_test.go index ffc679a93..d200fbbce 100644 --- a/pkg/cmd/workflow/enable/enable_test.go +++ b/pkg/cmd/workflow/enable/enable_test.go @@ -121,6 +121,7 @@ func TestEnableRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a workflow").AnswerWith("a disabled workflow (disabled.yml)") }, wantOut: "✓ Enabled a disabled workflow\n", @@ -176,6 +177,7 @@ func TestEnableRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Which workflow do you mean?").AnswerWith("a disabled workflow (anotherDisabled.yml)") }, wantOut: "✓ Enabled a disabled workflow\n", diff --git a/pkg/cmd/workflow/run/run_test.go b/pkg/cmd/workflow/run/run_test.go index 125e3fcfb..8622f4a24 100644 --- a/pkg/cmd/workflow/run/run_test.go +++ b/pkg/cmd/workflow/run/run_test.go @@ -558,6 +558,7 @@ jobs: httpmock.StatusStringResponse(204, "cool")) }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a workflow").AnswerDefault() }, wantBody: map[string]interface{}{ @@ -595,8 +596,11 @@ jobs: httpmock.StatusStringResponse(204, "cool")) }, askStubs: func(as *prompt.AskStubber) { + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("Select a workflow").AnswerDefault() + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("greeting").AnswerWith("hi") + //nolint:staticcheck // SA1019: as.StubPrompt is deprecated: use PrompterMock as.StubPrompt("name").AnswerWith("scully") }, wantBody: map[string]interface{}{ diff --git a/pkg/prompt/stubber.go b/pkg/prompt/stubber.go index 8d9e22520..51912cd70 100644 --- a/pkg/prompt/stubber.go +++ b/pkg/prompt/stubber.go @@ -18,6 +18,7 @@ type testing interface { Cleanup(func()) } +// Deprecated: use PrompterMock func NewAskStubber(t testing) *AskStubber { as, teardown := InitAskStubber() t.Cleanup(func() { @@ -31,7 +32,7 @@ func NewAskStubber(t testing) *AskStubber { return as } -// Deprecated: use NewAskStubber +// Deprecated: use PrompterMock func InitAskStubber() (*AskStubber, func()) { origSurveyAsk := SurveyAsk origSurveyAskOne := SurveyAskOne @@ -157,34 +158,38 @@ type QuestionStub struct { } // AssertOptions asserts the options presented to the user in Selects and MultiSelects. +// Deprecated: use PrompterMock func (s *QuestionStub) AssertOptions(opts []string) *QuestionStub { s.options = opts return s } // AnswerWith defines an answer for the given stub. +// Deprecated: use PrompterMock func (s *QuestionStub) AnswerWith(v interface{}) *QuestionStub { s.Value = v return s } // AnswerDefault marks the current stub to be answered with the default value for the prompt question. +// Deprecated: use PrompterMock func (s *QuestionStub) AnswerDefault() *QuestionStub { s.Default = true return s } -// Deprecated: use StubPrompt +// Deprecated: use PrompterMock func (as *AskStubber) StubOne(value interface{}) { as.Stub([]*QuestionStub{{Value: value}}) } -// Deprecated: use StubPrompt +// Deprecated: use PrompterMock func (as *AskStubber) Stub(stubbedQuestions []*QuestionStub) { as.stubs = append(as.stubs, stubbedQuestions...) } // StubPrompt records a stub for an interactive prompt matched by its message. +// Deprecated: use PrompterMock func (as *AskStubber) StubPrompt(msg string) *QuestionStub { stub := &QuestionStub{message: msg} as.stubs = append(as.stubs, stub)