From 531bfbc295693fa5ee765945ffb7d7e3913928f7 Mon Sep 17 00:00:00 2001 From: Toshiya Doi Date: Wed, 8 Apr 2020 15:08:08 +0900 Subject: [PATCH] Update unit tests for PR metadata --- command/pr_test.go | 37 +++++++++---------- .../prViewPreviewWithMetadataByBranch.json | 30 +++++++++++++-- ...=> prViewPreviewWithMetadataByNumber.json} | 17 +++++---- 3 files changed, 53 insertions(+), 31 deletions(-) rename test/fixtures/{prViewPreviewWithLotsOfMetadata.json => prViewPreviewWithMetadataByNumber.json} (91%) diff --git a/command/pr_test.go b/command/pr_test.go index 705792e82..00cabcbb9 100644 --- a/command/pr_test.go +++ b/command/pr_test.go @@ -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", diff --git a/test/fixtures/prViewPreviewWithMetadataByBranch.json b/test/fixtures/prViewPreviewWithMetadataByBranch.json index 5f58fc0fe..483b4d63c 100644 --- a/test/fixtures/prViewPreviewWithMetadataByBranch.json +++ b/test/fixtures/prViewPreviewWithMetadataByBranch.json @@ -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" diff --git a/test/fixtures/prViewPreviewWithLotsOfMetadata.json b/test/fixtures/prViewPreviewWithMetadataByNumber.json similarity index 91% rename from test/fixtures/prViewPreviewWithLotsOfMetadata.json rename to test/fixtures/prViewPreviewWithMetadataByNumber.json index b6cd1d7ca..24927cb19 100644 --- a/test/fixtures/prViewPreviewWithLotsOfMetadata.json +++ b/test/fixtures/prViewPreviewWithMetadataByNumber.json @@ -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