(t *testing.T)
| 2004 | } |
| 2005 | |
| 2006 | func TestPrAddToMergeQueueAdmin(t *testing.T) { |
| 2007 | http := initFakeHTTP() |
| 2008 | defer http.Verify(t) |
| 2009 | |
| 2010 | shared.StubFinderForRunCommandStyleTests(t, |
| 2011 | "1", |
| 2012 | &api.PullRequest{ |
| 2013 | ID: "THE-ID", |
| 2014 | Number: 1, |
| 2015 | State: "OPEN", |
| 2016 | Title: "The title of the PR", |
| 2017 | MergeStateStatus: "CLEAN", |
| 2018 | IsInMergeQueue: false, |
| 2019 | IsMergeQueueEnabled: true, |
| 2020 | }, |
| 2021 | baseRepo("OWNER", "REPO", "main"), |
| 2022 | ) |
| 2023 | |
| 2024 | http.Register( |
| 2025 | httpmock.GraphQL(`query RepositoryInfo\b`), |
| 2026 | httpmock.StringResponse(` |
| 2027 | { "data": { "repository": { |
| 2028 | "mergeCommitAllowed": true, |
| 2029 | "rebaseMergeAllowed": true, |
| 2030 | "squashMergeAllowed": true |
| 2031 | } } }`)) |
| 2032 | |
| 2033 | http.Register( |
| 2034 | httpmock.GraphQL(`mutation PullRequestMerge\b`), |
| 2035 | httpmock.GraphQLMutation(`{}`, func(input map[string]any) { |
| 2036 | assert.Equal(t, "THE-ID", input["pullRequestId"].(string)) |
| 2037 | assert.Equal(t, "MERGE", input["mergeMethod"].(string)) |
| 2038 | assert.NotContains(t, input, "commitHeadline") |
| 2039 | }), |
| 2040 | ) |
| 2041 | |
| 2042 | cs, cmdTeardown := run.Stub() |
| 2043 | defer cmdTeardown(t) |
| 2044 | cs.Register(`git rev-parse --verify refs/heads/`, 0, "") |
| 2045 | |
| 2046 | pm := &prompter.PrompterMock{ |
| 2047 | ConfirmFunc: func(p string, d bool) (bool, error) { |
| 2048 | if p == "Delete the branch locally and on GitHub?" { |
| 2049 | return d, nil |
| 2050 | } else { |
| 2051 | return false, prompter.NoSuchPromptErr(p) |
| 2052 | } |
| 2053 | }, |
| 2054 | SelectFunc: func(p, d string, opts []string) (int, error) { |
| 2055 | switch p { |
| 2056 | case "What's next?": |
| 2057 | return 0, nil |
| 2058 | case "What merge method would you like to use?": |
| 2059 | return 0, nil |
| 2060 | default: |
| 2061 | return -1, prompter.NoSuchPromptErr(p) |
| 2062 | } |
| 2063 | }, |
nothing calls this directly
no test coverage detected