Update unit tests for PR metadata

This commit is contained in:
Toshiya Doi 2020-04-08 15:08:08 +09:00
parent d07617817d
commit 531bfbc295
3 changed files with 53 additions and 31 deletions

View file

@ -416,11 +416,25 @@ func TestPRView_Preview(t *testing.T) {
expectedOutputs: []string{
`Blueberries are from a fork`,
`Open • nobody wants to merge 12 commits into master from blueberries`,
`Participants: marseilles\n`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
},
},
"Open PR with metadata by number": {
ownerRepo: "master",
args: "pr view 12",
fixture: "../test/fixtures/prViewPreviewWithMetadataByNumber.json",
expectedOutputs: []string{
`Blueberries are from a fork`,
`Open • nobody wants to merge 12 commits into master from blueberries`,
`Assignees: marseilles, monaco\n`,
`Labels: one, two, three, four, five\n`,
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\)\n`,
`Milestone: uluru\n`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12\n`,
},
},
"Open PR with metadata by branch": {
ownerRepo: "master",
args: "pr view blueberries",
@ -429,30 +443,13 @@ func TestPRView_Preview(t *testing.T) {
`Blueberries are a good fruit`,
`Open • nobody wants to merge 8 commits into master from blueberries`,
`Assignees: marseilles, monaco\n`,
`Labels: one, two, three\n`,
`Projects: The GitHub CLI \(to do list\)\n`,
`Labels: one, two, three, four, five\n`,
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\)\n`,
`Milestone: uluru\n`,
`Participants: marseilles, monaco, montpellier\n`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10\n`,
},
},
"Open PR with lots of metadata": {
ownerRepo: "master",
args: "pr view 12",
fixture: "../test/fixtures/prViewPreviewWithLotsOfMetadata.json",
expectedOutputs: []string{
`Blueberries are from a fork`,
`Open • nobody wants to merge 12 commits into master from blueberries`,
`Assignees: marseilles, monaco, montpellier, …\n`,
`Labels: one, two, three, …\n`,
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), …\n`,
`Milestone: uluru\n`,
`Participants: marseilles, monaco, montpellier, …\n`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
},
},
"Open PR for the current branch": {
ownerRepo: "blueberries",
args: "pr view",

View file

@ -76,22 +76,44 @@
},
{
"name": "three"
},
{
"name": "four"
},
{
"name": "five"
}
],
"totalcount": 3
"totalcount": 5
},
"projectcards": {
"nodes": [
{
"project": {
"name": "The GitHub CLI"
"name": "Project 1"
},
"column": {
"name": "to do list"
"name": "column A"
}
},
{
"project": {
"name": "Project 2"
},
"column": {
"name": "column B"
}
},
{
"project": {
"name": "Project 3"
},
"column": {
"name": "column C"
}
}
],
"totalcount": 1
"totalcount": 3
},
"milestone": {
"title": "uluru"

View file

@ -17,12 +17,9 @@
},
{
"login": "monaco"
},
{
"login": "montpellier"
}
],
"totalcount": 4
"totalcount": 2
},
"labels": {
"nodes": [
@ -34,9 +31,15 @@
},
{
"name": "three"
},
{
"name": "four"
},
{
"name": "five"
}
],
"totalcount": 4
"totalcount": 5
},
"projectcards": {
"nodes": [
@ -65,7 +68,7 @@
}
}
],
"totalcount": 4
"totalcount": 3
},
"milestone": {
"title": "uluru"
@ -82,7 +85,7 @@
"login": "montpellier"
}
],
"totalcount": 4
"totalcount": 3
},
"commits": {
"totalCount": 12