MCPcopy
hub / github.com/cli/cli / Test_ViewRun_NoDescription

Function Test_ViewRun_NoDescription

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

Source from the content-addressed store, hash-verified

505}
506
507func Test_ViewRun_NoDescription(t *testing.T) {
508 tests := []struct {
509 name string
510 stdoutTTY bool
511 wantOut string
512 }{
513 {
514 name: "tty",
515 wantOut: heredoc.Doc(`
516 OWNER/REPO
517 No description provided
518
519 # truly cool readme check it out
520
521 View this repository on GitHub: https://github.com/OWNER/REPO
522 `),
523 stdoutTTY: true,
524 },
525 {
526 name: "nontty",
527 wantOut: heredoc.Doc(`
528 name: OWNER/REPO
529 description:
530 --
531 # truly cool readme check it out
532 `),
533 },
534 }
535
536 for _, tt := range tests {
537 reg := &httpmock.Registry{}
538 reg.Register(
539 httpmock.GraphQL(`query RepositoryInfo\b`),
540 httpmock.StringResponse(`
541 { "data": {
542 "repository": {
543 "description": ""
544 } } }`))
545 reg.Register(
546 httpmock.REST("GET", "repos/OWNER/REPO/readme"),
547 httpmock.StringResponse(`
548 { "name": "readme.org",
549 "content": "IyB0cnVseSBjb29sIHJlYWRtZSBjaGVjayBpdCBvdXQ="}`))
550
551 opts := &ViewOptions{
552 HttpClient: func() (*http.Client, error) {
553 return &http.Client{Transport: reg}, nil
554 },
555 BaseRepo: func() (ghrepo.Interface, error) {
556 return ghrepo.New("OWNER", "REPO"), nil
557 },
558 }
559
560 io, _, stdout, stderr := iostreams.Test()
561
562 opts.IO = io
563
564 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