(t *testing.T)
| 1475 | } |
| 1476 | |
| 1477 | func TestPRMergeTTY_squashEditCommitMsgAndSubject(t *testing.T) { |
| 1478 | ios, _, stdout, stderr := iostreams.Test() |
| 1479 | ios.SetStdinTTY(true) |
| 1480 | ios.SetStdoutTTY(true) |
| 1481 | ios.SetStderrTTY(true) |
| 1482 | |
| 1483 | tr := initFakeHTTP() |
| 1484 | defer tr.Verify(t) |
| 1485 | |
| 1486 | tr.Register( |
| 1487 | httpmock.GraphQL(`query RepositoryInfo\b`), |
| 1488 | httpmock.StringResponse(` |
| 1489 | { "data": { "repository": { |
| 1490 | "mergeCommitAllowed": true, |
| 1491 | "rebaseMergeAllowed": true, |
| 1492 | "squashMergeAllowed": true |
| 1493 | } } }`)) |
| 1494 | tr.Register( |
| 1495 | httpmock.GraphQL(`query PullRequestMergeText\b`), |
| 1496 | httpmock.StringResponse(` |
| 1497 | { "data": { "node": { |
| 1498 | "viewerMergeHeadlineText": "default headline text", |
| 1499 | "viewerMergeBodyText": "default body text" |
| 1500 | } } }`)) |
| 1501 | tr.Register( |
| 1502 | httpmock.GraphQL(`query PullRequestMergeText\b`), |
| 1503 | httpmock.StringResponse(` |
| 1504 | { "data": { "node": { |
| 1505 | "viewerMergeHeadlineText": "default headline text", |
| 1506 | "viewerMergeBodyText": "default body text" |
| 1507 | } } }`)) |
| 1508 | tr.Register( |
| 1509 | httpmock.GraphQL(`mutation PullRequestMerge\b`), |
| 1510 | httpmock.GraphQLMutation(`{}`, func(input map[string]interface{}) { |
| 1511 | assert.Equal(t, "THE-ID", input["pullRequestId"].(string)) |
| 1512 | assert.Equal(t, "SQUASH", input["mergeMethod"].(string)) |
| 1513 | assert.Equal(t, "DEFAULT HEADLINE TEXT", input["commitHeadline"].(string)) |
| 1514 | assert.Equal(t, "DEFAULT BODY TEXT", input["commitBody"].(string)) |
| 1515 | })) |
| 1516 | |
| 1517 | _, cmdTeardown := run.Stub() |
| 1518 | defer cmdTeardown(t) |
| 1519 | |
| 1520 | selectCount := -1 |
| 1521 | answers := []string{"Edit commit message", "Edit commit subject", "Submit"} |
| 1522 | |
| 1523 | pm := &prompter.PrompterMock{ |
| 1524 | ConfirmFunc: func(p string, d bool) (bool, error) { |
| 1525 | if p == "Delete the branch on GitHub?" { |
| 1526 | return d, nil |
| 1527 | } else { |
| 1528 | return false, prompter.NoSuchPromptErr(p) |
| 1529 | } |
| 1530 | }, |
| 1531 | SelectFunc: func(p, d string, opts []string) (int, error) { |
| 1532 | switch p { |
| 1533 | case "What's next?": |
| 1534 | selectCount++ |
nothing calls this directly
no test coverage detected