MCPcopy Create free account
hub / github.com/cli/cli / TestIssueView_tty_Preview

Function TestIssueView_tty_Preview

pkg/cmd/issue/view/view_test.go:245–341  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

243}
244
245func TestIssueView_tty_Preview(t *testing.T) {
246 tests := map[string]struct {
247 httpStubs func(*httpmock.Registry)
248 expectedOutputs []string
249 }{
250 "Open issue without metadata": {
251 httpStubs: func(r *httpmock.Registry) {
252 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_preview.json"))
253 mockEmptyV2ProjectItems(t, r)
254 },
255 expectedOutputs: []string{
256 `ix of coins OWNER/REPO#123`,
257 `Open.*marseilles opened about 9 years ago.*9 comments`,
258 `bold story`,
259 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
260 },
261 },
262 "Open issue with metadata": {
263 httpStubs: func(r *httpmock.Registry) {
264 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithMetadata.json"))
265 mockV2ProjectItems(t, r)
266 },
267 expectedOutputs: []string{
268 `ix of coins OWNER/REPO#123`,
269 `Open.*marseilles opened about 9 years ago.*9 comments`,
270 `8 \x{1f615} • 7 \x{1f440} • 6 \x{2764}\x{fe0f} • 5 \x{1f389} • 4 \x{1f604} • 3 \x{1f680} • 2 \x{1f44e} • 1 \x{1f44d}`,
271 `Assignees:.*marseilles, monaco\n`,
272 `Labels:.*Closed: Duplicate, Closed: Won't Fix, help wanted, Status: In Progress, Type: Bug\n`,
273 `Projects:.*v2 Project 1 \(No Status\), v2 Project 2 \(Done\), Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), Project 4 \(Awaiting triage\)\n`,
274 `Milestone:.*uluru\n`,
275 `bold story`,
276 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
277 },
278 },
279 "Open issue with empty body": {
280 httpStubs: func(r *httpmock.Registry) {
281 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithEmptyBody.json"))
282 mockEmptyV2ProjectItems(t, r)
283 },
284 expectedOutputs: []string{
285 `ix of coins OWNER/REPO#123`,
286 `Open.*marseilles opened about 9 years ago.*9 comments`,
287 `No description provided`,
288 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
289 },
290 },
291 "Closed issue": {
292 httpStubs: func(r *httpmock.Registry) {
293 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewClosedState.json"))
294 mockEmptyV2ProjectItems(t, r)
295 },
296 expectedOutputs: []string{
297 `ix of coins OWNER/REPO#123`,
298 `Closed.*marseilles opened about 9 years ago.*9 comments`,
299 `bold story`,
300 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
301 },
302 },

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
GraphQLFunction · 0.92
FileResponseFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
ExpectLinesFunction · 0.92
mockEmptyV2ProjectItemsFunction · 0.85
mockV2ProjectItemsFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected