Skip to content

Commit 531bfbc

Browse files
committed
Update unit tests for PR metadata
1 parent d076178 commit 531bfbc

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

command/pr_test.go

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -416,41 +416,38 @@ func TestPRView_Preview(t *testing.T) {
416416
expectedOutputs: []string{
417417
`Blueberries are from a fork`,
418418
`Open • nobody wants to merge 12 commits into master from blueberries`,
419-
`Participants: marseilles\n`,
420419
`blueberries taste good`,
421420
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
422421
},
423422
},
424-
"Open PR with metadata by branch": {
423+
"Open PR with metadata by number": {
425424
ownerRepo: "master",
426-
args: "pr view blueberries",
427-
fixture: "../test/fixtures/prViewPreviewWithMetadataByBranch.json",
425+
args: "pr view 12",
426+
fixture: "../test/fixtures/prViewPreviewWithMetadataByNumber.json",
428427
expectedOutputs: []string{
429-
`Blueberries are a good fruit`,
430-
`Open • nobody wants to merge 8 commits into master from blueberries`,
428+
`Blueberries are from a fork`,
429+
`Open • nobody wants to merge 12 commits into master from blueberries`,
431430
`Assignees: marseilles, monaco\n`,
432-
`Labels: one, two, three\n`,
433-
`Projects: The GitHub CLI \(to do list\)\n`,
431+
`Labels: one, two, three, four, five\n`,
432+
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\)\n`,
434433
`Milestone: uluru\n`,
435-
`Participants: marseilles, monaco, montpellier\n`,
436434
`blueberries taste good`,
437-
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10\n`,
435+
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12\n`,
438436
},
439437
},
440-
"Open PR with lots of metadata": {
438+
"Open PR with metadata by branch": {
441439
ownerRepo: "master",
442-
args: "pr view 12",
443-
fixture: "../test/fixtures/prViewPreviewWithLotsOfMetadata.json",
440+
args: "pr view blueberries",
441+
fixture: "../test/fixtures/prViewPreviewWithMetadataByBranch.json",
444442
expectedOutputs: []string{
445-
`Blueberries are from a fork`,
446-
`Open • nobody wants to merge 12 commits into master from blueberries`,
447-
`Assignees: marseilles, monaco, montpellier, …\n`,
448-
`Labels: one, two, three, \n`,
449-
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), …\n`,
443+
`Blueberries are a good fruit`,
444+
`Open • nobody wants to merge 8 commits into master from blueberries`,
445+
`Assignees: marseilles, monaco\n`,
446+
`Labels: one, two, three, four, five\n`,
447+
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\)\n`,
450448
`Milestone: uluru\n`,
451-
`Participants: marseilles, monaco, montpellier, …\n`,
452449
`blueberries taste good`,
453-
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
450+
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10\n`,
454451
},
455452
},
456453
"Open PR for the current branch": {

test/fixtures/prViewPreviewWithMetadataByBranch.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,44 @@
7676
},
7777
{
7878
"name": "three"
79+
},
80+
{
81+
"name": "four"
82+
},
83+
{
84+
"name": "five"
7985
}
8086
],
81-
"totalcount": 3
87+
"totalcount": 5
8288
},
8389
"projectcards": {
8490
"nodes": [
8591
{
8692
"project": {
87-
"name": "The GitHub CLI"
93+
"name": "Project 1"
8894
},
8995
"column": {
90-
"name": "to do list"
96+
"name": "column A"
97+
}
98+
},
99+
{
100+
"project": {
101+
"name": "Project 2"
102+
},
103+
"column": {
104+
"name": "column B"
105+
}
106+
},
107+
{
108+
"project": {
109+
"name": "Project 3"
110+
},
111+
"column": {
112+
"name": "column C"
91113
}
92114
}
93115
],
94-
"totalcount": 1
116+
"totalcount": 3
95117
},
96118
"milestone": {
97119
"title": "uluru"

test/fixtures/prViewPreviewWithLotsOfMetadata.json renamed to test/fixtures/prViewPreviewWithMetadataByNumber.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
},
1818
{
1919
"login": "monaco"
20-
},
21-
{
22-
"login": "montpellier"
2320
}
2421
],
25-
"totalcount": 4
22+
"totalcount": 2
2623
},
2724
"labels": {
2825
"nodes": [
@@ -34,9 +31,15 @@
3431
},
3532
{
3633
"name": "three"
34+
},
35+
{
36+
"name": "four"
37+
},
38+
{
39+
"name": "five"
3740
}
3841
],
39-
"totalcount": 4
42+
"totalcount": 5
4043
},
4144
"projectcards": {
4245
"nodes": [
@@ -65,7 +68,7 @@
6568
}
6669
}
6770
],
68-
"totalcount": 4
71+
"totalcount": 3
6972
},
7073
"milestone": {
7174
"title": "uluru"
@@ -82,7 +85,7 @@
8285
"login": "montpellier"
8386
}
8487
],
85-
"totalcount": 4
88+
"totalcount": 3
8689
},
8790
"commits": {
8891
"totalCount": 12

0 commit comments

Comments
 (0)