Test issue metadata in CLI preview

This commit is contained in:
Toshiya Doi 2020-04-03 22:30:58 +09:00
parent bfb3501cf9
commit 8c697a0d99
5 changed files with 260 additions and 46 deletions

View file

@ -292,26 +292,48 @@ func TestIssueView_Preview(t *testing.T) {
fixture string
expectedOutputs []string
}{
"Open issue": {
"Open issue without metadata": {
ownerRepo: "master",
command: "issue view 123",
fixture: "../test/fixtures/issueView_preview.json",
expectedOutputs: []string{
"ix of coins",
"Open • marseilles opened about 292 years ago • 9 comments",
"bold story",
"View this issue on GitHub: https://github.com/OWNER/REPO/issues/123",
`ix of coins`,
`Open • marseilles opened about 292 years ago • 9 comments`,
`Participants: marseilles`,
`bold story`,
`View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
},
},
"Open issue with no label": {
"Open issue with metadata": {
ownerRepo: "master",
command: "issue view 123",
fixture: "../test/fixtures/issueView_previewNoLabel.json",
fixture: "../test/fixtures/issueView_previewWithMetadata.json",
expectedOutputs: []string{
"ix of coins",
"Open • marseilles opened about 292 years ago • 9 comments",
"bold story",
"View this issue on GitHub: https://github.com/OWNER/REPO/issues/123",
`ix of coins`,
`Open • marseilles opened about 292 years ago • 9 comments`,
`Assignees: marseilles, monaco`,
`Labels: one, two, three`,
`Projects: The GitHub CLI \(to do list\)`,
`Milestone: uluru`,
`Participants: marseilles, monaco, montpellier`,
`bold story`,
`View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
},
},
"Open issue with lots of metadata": {
ownerRepo: "master",
command: "issue view 123",
fixture: "../test/fixtures/issueView_previewWithLotsOfMetadata.json",
expectedOutputs: []string{
`ix of coins`,
`Open • marseilles opened about 292 years ago • 9 comments`,
`Assignees: marseilles, monaco, montpellier, …`,
`Labels: one, two, three, …`,
`Projects: Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), …`,
`Milestone: uluru`,
`Participants: marseilles, monaco, montpellier, …`,
`bold story`,
`View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
},
},
"Open issue with empty body": {
@ -319,9 +341,9 @@ func TestIssueView_Preview(t *testing.T) {
command: "issue view 123",
fixture: "../test/fixtures/issueView_previewWithEmptyBody.json",
expectedOutputs: []string{
"ix of coins",
"Open • marseilles opened about 292 years ago • 9 comments",
"View this issue on GitHub: https://github.com/OWNER/REPO/issues/123",
`ix of coins`,
`Open • marseilles opened about 292 years ago • 9 comments`,
`View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
},
},
"Closed issue": {
@ -329,10 +351,10 @@ func TestIssueView_Preview(t *testing.T) {
command: "issue view 123",
fixture: "../test/fixtures/issueView_previewClosedState.json",
expectedOutputs: []string{
"ix of coins",
"Closed • marseilles opened about 292 years ago • 9 comments",
"bold story",
"View this issue on GitHub: https://github.com/OWNER/REPO/issues/123",
`ix of coins`,
`Closed • marseilles opened about 292 years ago • 9 comments`,
`bold story`,
`View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
},
},
}

View file

@ -11,12 +11,30 @@
"author": {
"login": "marseilles"
},
"assignees": {
"edges": [],
"totalcount": 0
},
"labels": {
"nodes": [
"nodes": [],
"totalcount": 0
},
"projectcards": {
"edges": [],
"totalcount": 0
},
"milestone": {
"title": ""
},
"participants": {
"edges": [
{
"name": "tarot"
"node": {
"login": "marseilles"
}
}
]
],
"totalcount": 1
},
"comments": {
"totalCount": 9

View file

@ -1,25 +0,0 @@
{
"data": {
"repository": {
"hasIssuesEnabled": true,
"issue": {
"number": 123,
"body": "**bold story**",
"title": "ix of coins",
"state": "OPEN",
"created_at": "2011-01-26T19:01:12Z",
"author": {
"login": "marseilles"
},
"labels": {
"nodes": [
]
},
"comments": {
"totalCount": 9
},
"url": "https://github.com/OWNER/REPO/issues/123"
}
}
}
}

View file

@ -0,0 +1,112 @@
{
"data": {
"repository": {
"hasIssuesEnabled": true,
"issue": {
"number": 123,
"body": "**bold story**",
"title": "ix of coins",
"state": "OPEN",
"created_at": "2011-01-26T19:01:12Z",
"author": {
"login": "marseilles"
},
"assignees": {
"edges": [
{ "node": {
"login": "marseilles"
}
},
{
"node": {
"login": "monaco"
}
},
{
"node": {
"login": "montpellier"
}
}
],
"totalcount": 4
},
"labels": {
"nodes": [
{
"name": "one"
},
{
"name": "two"
},
{
"name": "three"
}
],
"totalcount": 4
},
"projectcards": {
"edges": [
{
"node": {
"project": {
"name": "Project 1"
},
"column": {
"name": "column A"
}
}
},
{
"node": {
"project": {
"name": "Project 2"
},
"column": {
"name": "column B"
}
}
},
{
"node": {
"project": {
"name": "Project 3"
},
"column": {
"name": "column C"
}
}
}
],
"totalcount": 4
},
"milestone": {
"title": "uluru"
},
"participants": {
"edges": [
{
"node": {
"login": "marseilles"
}
},
{
"node": {
"login": "monaco"
}
},
{
"node": {
"login": "montpellier"
}
}
],
"totalcount": 4
},
"comments": {
"totalcount": 9
},
"url": "https://github.com/OWNER/REPO/issues/123"
}
}
}
}

View file

@ -0,0 +1,87 @@
{
"data": {
"repository": {
"hasIssuesEnabled": true,
"issue": {
"number": 123,
"body": "**bold story**",
"title": "ix of coins",
"state": "OPEN",
"created_at": "2011-01-26T19:01:12Z",
"author": {
"login": "marseilles"
},
"assignees": {
"edges": [
{ "node": {
"login": "marseilles"
}
},
{
"node": {
"login": "monaco"
}
}
],
"totalcount": 2
},
"labels": {
"nodes": [
{
"name": "one"
},
{
"name": "two"
},
{
"name": "three"
}
],
"totalcount": 3
},
"projectcards": {
"edges": [
{
"node": {
"project": {
"name": "The GitHub CLI"
},
"column": {
"name": "to do list"
}
}
}
],
"totalcount": 1
},
"milestone": {
"title": "uluru"
},
"participants": {
"edges": [
{
"node": {
"login": "marseilles"
}
},
{
"node": {
"login": "monaco"
}
},
{
"node": {
"login": "montpellier"
}
}
],
"totalcount": 3
},
"comments": {
"totalcount": 9
},
"url": "https://github.com/OWNER/REPO/issues/123"
}
}
}
}