Test pr metadata in CLI preview

This commit is contained in:
Toshiya Doi 2020-04-04 13:14:34 +09:00
parent 0cb6890c74
commit 85d8f808f2
4 changed files with 310 additions and 28 deletions

View file

@ -409,15 +409,48 @@ func TestPRView_Preview(t *testing.T) {
fixture string
expectedOutputs []string
}{
"Open PR": {
"Open PR without metadata": {
ownerRepo: "master",
args: "pr view 12",
fixture: "../test/fixtures/prViewPreview.json",
expectedOutputs: []string{
"Blueberries are from a fork",
"Open • nobody wants to merge 12 commits into master from blueberries",
"blueberries taste good",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12",
`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 branch": {
ownerRepo: "master",
args: "pr view blueberries",
fixture: "../test/fixtures/prViewPreviewWithMetadataByBranch.json",
expectedOutputs: []string{
`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`,
`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": {
@ -425,10 +458,10 @@ func TestPRView_Preview(t *testing.T) {
args: "pr view",
fixture: "../test/fixtures/prView.json",
expectedOutputs: []string{
"Blueberries are a good fruit",
"Open • nobody wants to merge 8 commits into master from blueberries",
"blueberries taste good",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10",
`Blueberries are a good fruit`,
`Open • nobody wants to merge 8 commits into master from blueberries`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10`,
},
},
"Open PR wth empty body for the current branch": {
@ -436,9 +469,9 @@ func TestPRView_Preview(t *testing.T) {
args: "pr view",
fixture: "../test/fixtures/prView_EmptyBody.json",
expectedOutputs: []string{
"Blueberries are a good fruit",
"Open • nobody wants to merge 8 commits into master from blueberries",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10",
`Blueberries are a good fruit`,
`Open • nobody wants to merge 8 commits into master from blueberries`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10`,
},
},
"Closed PR": {
@ -446,10 +479,10 @@ func TestPRView_Preview(t *testing.T) {
args: "pr view 12",
fixture: "../test/fixtures/prViewPreviewClosedState.json",
expectedOutputs: []string{
"Blueberries are from a fork",
"Closed • nobody wants to merge 12 commits into master from blueberries",
"blueberries taste good",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12",
`Blueberries are from a fork`,
`Closed • nobody wants to merge 12 commits into master from blueberries`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
},
},
"Merged PR": {
@ -457,10 +490,10 @@ func TestPRView_Preview(t *testing.T) {
args: "pr view 12",
fixture: "../test/fixtures/prViewPreviewMergedState.json",
expectedOutputs: []string{
"Blueberries are from a fork",
"Merged • nobody wants to merge 12 commits into master from blueberries",
"blueberries taste good",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12",
`Blueberries are from a fork`,
`Merged • nobody wants to merge 12 commits into master from blueberries`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
},
},
"Draft PR": {
@ -468,10 +501,10 @@ func TestPRView_Preview(t *testing.T) {
args: "pr view 12",
fixture: "../test/fixtures/prViewPreviewDraftState.json",
expectedOutputs: []string{
"Blueberries are from a fork",
"Draft • nobody wants to merge 12 commits into master from blueberries",
"blueberries taste good",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12",
`Blueberries are from a fork`,
`Draft • nobody wants to merge 12 commits into master from blueberries`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
},
},
"Draft PR by branch": {
@ -479,10 +512,10 @@ func TestPRView_Preview(t *testing.T) {
args: "pr view blueberries",
fixture: "../test/fixtures/prViewPreviewDraftStatebyBranch.json",
expectedOutputs: []string{
"Blueberries are a good fruit",
"Draft • nobody wants to merge 8 commits into master from blueberries",
"blueberries taste good",
"View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10",
`Blueberries are a good fruit`,
`Draft • nobody wants to merge 8 commits into master from blueberries`,
`blueberries taste good`,
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/10`,
},
},
}

View file

@ -10,6 +10,29 @@
"author": {
"login": "nobody"
},
"assignees": {
"nodes": [],
"totalcount": 0
},
"labels": {
"nodes": [],
"totalcount": 0
},
"projectcards": {
"nodes": [],
"totalcount": 0
},
"milestone": {
"title": ""
},
"participants": {
"nodes": [
{
"login": "marseilles"
}
],
"totalcount": 1
},
"commits": {
"totalCount": 12
},

View file

@ -0,0 +1,100 @@
{
"data": {
"repository": {
"pullRequest": {
"number": 12,
"title": "Blueberries are from a fork",
"state": "OPEN",
"body": "**blueberries taste good**",
"url": "https://github.com/OWNER/REPO/pull/12",
"author": {
"login": "nobody"
},
"assignees": {
"nodes": [
{
"login": "marseilles"
},
{
"login": "monaco"
},
{
"login": "montpellier"
}
],
"totalcount": 4
},
"labels": {
"nodes": [
{
"name": "one"
},
{
"name": "two"
},
{
"name": "three"
}
],
"totalcount": 4
},
"projectcards": {
"nodes": [
{
"project": {
"name": "Project 1"
},
"column": {
"name": "column A"
}
},
{
"project": {
"name": "Project 2"
},
"column": {
"name": "column B"
}
},
{
"project": {
"name": "Project 3"
},
"column": {
"name": "column C"
}
}
],
"totalcount": 4
},
"milestone": {
"title": "uluru"
},
"participants": {
"nodes": [
{
"login": "marseilles"
},
{
"login": "monaco"
},
{
"login": "montpellier"
}
],
"totalcount": 4
},
"commits": {
"totalCount": 12
},
"baseRefName": "master",
"headRefName": "blueberries",
"headRepositoryOwner": {
"login": "hubot"
},
"isCrossRepository": true,
"isDraft": false
}
}
}
}

View file

@ -0,0 +1,126 @@
{
"data": {
"repository": {
"pullRequests": {
"nodes": [
{
"number": 12,
"title": "Blueberries are from a fork",
"state": "OPEN",
"body": "yeah",
"url": "https://github.com/OWNER/REPO/pull/12",
"headRefName": "blueberries",
"baseRefName": "master",
"headRepositoryOwner": {
"login": "hubot"
},
"assignees": {
"nodes": [],
"totalcount": 0
},
"labels": {
"nodes": [],
"totalcount": 0
},
"projectcards": {
"nodes": [],
"totalcount": 0
},
"milestone": {},
"participants": {
"nodes": [
{
"login": "nobody"
}
],
"totalcount": 1
},
"commits": {
"totalCount": 12
},
"author": {
"login": "nobody"
},
"isCrossRepository": true,
"isDraft": false
},
{
"number": 10,
"title": "Blueberries are a good fruit",
"state": "OPEN",
"body": "**blueberries taste good**",
"url": "https://github.com/OWNER/REPO/pull/10",
"baseRefName": "master",
"headRefName": "blueberries",
"author": {
"login": "nobody"
},
"assignees": {
"nodes": [
{
"login": "marseilles"
},
{
"login": "monaco"
}
],
"totalcount": 2
},
"labels": {
"nodes": [
{
"name": "one"
},
{
"name": "two"
},
{
"name": "three"
}
],
"totalcount": 3
},
"projectcards": {
"nodes": [
{
"project": {
"name": "The GitHub CLI"
},
"column": {
"name": "to do list"
}
}
],
"totalcount": 1
},
"milestone": {
"title": "uluru"
},
"participants": {
"nodes": [
{
"login": "marseilles"
},
{
"login": "monaco"
},
{
"login": "montpellier"
}
],
"totalcount": 3
},
"headRepositoryOwner": {
"login": "OWNER"
},
"commits": {
"totalCount": 8
},
"isCrossRepository": false,
"isDraft": false
}
]
}
}
}
}