MCPcopy
hub / github.com/cli/cli / Test_ViewRun_NonMarkdownReadme

Function Test_ViewRun_NonMarkdownReadme

pkg/cmd/repo/view/view_test.go:371–439  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

369}
370
371func Test_ViewRun_NonMarkdownReadme(t *testing.T) {
372 tests := []struct {
373 name string
374 stdoutTTY bool
375 wantOut string
376 }{
377 {
378 name: "tty",
379 wantOut: heredoc.Doc(`
380 OWNER/REPO
381 social distancing
382
383 # truly cool readme check it out
384
385 View this repository on GitHub: https://github.com/OWNER/REPO
386 `),
387 stdoutTTY: true,
388 },
389 {
390 name: "nontty",
391 wantOut: heredoc.Doc(`
392 name: OWNER/REPO
393 description: social distancing
394 --
395 # truly cool readme check it out
396 `),
397 },
398 }
399
400 for _, tt := range tests {
401 reg := &httpmock.Registry{}
402 reg.Register(
403 httpmock.GraphQL(`query RepositoryInfo\b`),
404 httpmock.StringResponse(`
405 { "data": {
406 "repository": {
407 "description": "social distancing"
408 } } }`))
409 reg.Register(
410 httpmock.REST("GET", "repos/OWNER/REPO/readme"),
411 httpmock.StringResponse(`
412 { "name": "readme.org",
413 "content": "IyB0cnVseSBjb29sIHJlYWRtZSBjaGVjayBpdCBvdXQ="}`))
414
415 opts := &ViewOptions{
416 HttpClient: func() (*http.Client, error) {
417 return &http.Client{Transport: reg}, nil
418 },
419 BaseRepo: func() (ghrepo.Interface, error) {
420 return ghrepo.New("OWNER", "REPO"), nil
421 },
422 }
423
424 io, _, stdout, stderr := iostreams.Test()
425
426 opts.IO = io
427
428 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 13

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
RESTFunction · 0.92
NewFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
viewRunFunction · 0.70
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected