Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
include realistic id in JSON output test stubs
Address Copilot review feedback: mock responses for JSON output tests
now include a realistic PR node ID instead of relying on the zero value,
ensuring the id field mapping is validated end-to-end.
  • Loading branch information
SebTardif committed May 4, 2026
commit 2cd48dc3741585389ca1a788cb5969720ce2d2a7
10 changes: 7 additions & 3 deletions pkg/cmd/pr/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ func Test_createRun(t *testing.T) {
httpmock.GraphQL(`mutation PullRequestCreate\b`),
httpmock.GraphQLMutation(`
{ "data": { "createPullRequest": { "pullRequest": {
"ID": "PR_kwDOA1KnGc6WELLE",
"Number": 12,
"URL": "https://github.com/OWNER/REPO/pull/12"
} } } }`,
Expand All @@ -439,7 +440,7 @@ func Test_createRun(t *testing.T) {
opts.Exporter = exporter
return func() {}
},
expectedOut: "{\"id\":\"\",\"number\":12,\"url\":\"https://github.com/OWNER/REPO/pull/12\"}\n",
expectedOut: "{\"id\":\"PR_kwDOA1KnGc6WELLE\",\"number\":12,\"url\":\"https://github.com/OWNER/REPO/pull/12\"}\n",
},
Comment on lines +416 to +444
{
name: "tty json output",
Expand All @@ -449,6 +450,7 @@ func Test_createRun(t *testing.T) {
httpmock.GraphQL(`mutation PullRequestCreate\b`),
httpmock.GraphQLMutation(`
{ "data": { "createPullRequest": { "pullRequest": {
"ID": "PR_kwDOA1KnGc6WELLE",
"Number": 12,
"URL": "https://github.com/OWNER/REPO/pull/12"
} } } }`,
Expand All @@ -465,7 +467,7 @@ func Test_createRun(t *testing.T) {
opts.Exporter = exporter
return func() {}
},
expectedOut: "{\"id\":\"\",\"number\":12,\"url\":\"https://github.com/OWNER/REPO/pull/12\"}\n",
expectedOut: "{\"id\":\"PR_kwDOA1KnGc6WELLE\",\"number\":12,\"url\":\"https://github.com/OWNER/REPO/pull/12\"}\n",
expectedErrOut: "\nCreating pull request for feature into master in OWNER/REPO\n\n",
},
Comment on lines +446 to +472
{
Expand All @@ -475,6 +477,7 @@ func Test_createRun(t *testing.T) {
httpmock.GraphQL(`mutation PullRequestCreate\b`),
httpmock.GraphQLMutation(`
{ "data": { "createPullRequest": { "pullRequest": {
"ID": "PR_kwDOA1KnGc6WELLE",
"Number": 12,
"URL": "https://github.com/OWNER/REPO/pull/12"
} } } }`,
Expand All @@ -501,6 +504,7 @@ func Test_createRun(t *testing.T) {
httpmock.GraphQL(`mutation PullRequestCreate\b`),
httpmock.GraphQLMutation(`
{ "data": { "createPullRequest": { "pullRequest": {
"ID": "PR_kwDOA1KnGc6WELLE",
"Number": 12,
"URL": "https://github.com/OWNER/REPO/pull/12"
} } } }`,
Expand All @@ -520,7 +524,7 @@ func Test_createRun(t *testing.T) {
opts.Exporter = exporter
return func() {}
},
expectedOut: "{\"id\":\"\",\"number\":12,\"url\":\"https://github.com/OWNER/REPO/pull/12\"}\n",
expectedOut: "{\"id\":\"PR_kwDOA1KnGc6WELLE\",\"number\":12,\"url\":\"https://github.com/OWNER/REPO/pull/12\"}\n",
},
Comment on lines +501 to +528
{
name: "json output does not print URL",
Expand Down