@@ -552,8 +552,7 @@ func TestRepoCreate_orgWithTeam(t *testing.T) {
552552 }
553553}
554554
555-
556- func TestRepoView (t * testing.T ) {
555+ func TestRepoView_web (t * testing.T ) {
557556 initBlankContext ("OWNER/REPO" , "master" )
558557 http := initFakeHTTP ()
559558 http .StubRepoResponse ("OWNER" , "REPO" )
@@ -568,7 +567,7 @@ func TestRepoView(t *testing.T) {
568567 })
569568 defer restoreCmd ()
570569
571- output , err := RunCommand (repoViewCmd , "repo view" )
570+ output , err := RunCommand (repoViewCmd , "repo view -w " )
572571 if err != nil {
573572 t .Errorf ("error running command `repo view`: %v" , err )
574573 }
@@ -583,7 +582,7 @@ func TestRepoView(t *testing.T) {
583582 eq (t , url , "https://github.com/OWNER/REPO" )
584583}
585584
586- func TestRepoView_ownerRepo (t * testing.T ) {
585+ func TestRepoView_web_ownerRepo (t * testing.T ) {
587586 ctx := context .NewBlank ()
588587 ctx .SetBranch ("master" )
589588 initContext = func () context.Context {
@@ -601,7 +600,7 @@ func TestRepoView_ownerRepo(t *testing.T) {
601600 })
602601 defer restoreCmd ()
603602
604- output , err := RunCommand (repoViewCmd , "repo view cli/cli" )
603+ output , err := RunCommand (repoViewCmd , "repo view -w cli/cli" )
605604 if err != nil {
606605 t .Errorf ("error running command `repo view`: %v" , err )
607606 }
@@ -616,7 +615,7 @@ func TestRepoView_ownerRepo(t *testing.T) {
616615 eq (t , url , "https://github.com/cli/cli" )
617616}
618617
619- func TestRepoView_fullURL (t * testing.T ) {
618+ func TestRepoView_web_fullURL (t * testing.T ) {
620619 ctx := context .NewBlank ()
621620 ctx .SetBranch ("master" )
622621 initContext = func () context.Context {
@@ -633,7 +632,7 @@ func TestRepoView_fullURL(t *testing.T) {
633632 })
634633 defer restoreCmd ()
635634
636- output , err := RunCommand (repoViewCmd , "repo view https://github.com/cli/cli" )
635+ output , err := RunCommand (repoViewCmd , "repo view -w https://github.com/cli/cli" )
637636 if err != nil {
638637 t .Errorf ("error running command `repo view`: %v" , err )
639638 }
@@ -647,3 +646,77 @@ func TestRepoView_fullURL(t *testing.T) {
647646 url := seenCmd .Args [len (seenCmd .Args )- 1 ]
648647 eq (t , url , "https://github.com/cli/cli" )
649648}
649+
650+ func TestRepoView (t * testing.T ) {
651+ initBlankContext ("OWNER/REPO" , "master" )
652+ http := initFakeHTTP ()
653+ http .StubRepoResponse ("OWNER" , "REPO" )
654+ http .StubResponse (200 , bytes .NewBufferString (`
655+ { "data": {
656+ "repository": {
657+ "description": "social distancing"
658+ }}}
659+ ` ))
660+ http .StubResponse (200 , bytes .NewBufferString (`
661+ { "name": "readme.md",
662+ "content": "IyB0cnVseSBjb29sIHJlYWRtZSBjaGVjayBpdCBvdXQ="}
663+ ` ))
664+
665+ output , err := RunCommand (repoViewCmd , "repo view" )
666+ if err != nil {
667+ t .Errorf ("error running command `repo view`: %v" , err )
668+ }
669+
670+ test .ExpectLines (t , output .String (),
671+ "OWNER/REPO" ,
672+ "social distancing" ,
673+ "truly cool readme" ,
674+ "View this repository on GitHub: https://github.com/OWNER/REPO" )
675+
676+ }
677+
678+ func TestRepoView_nonmarkdown_readme (t * testing.T ) {
679+ initBlankContext ("OWNER/REPO" , "master" )
680+ http := initFakeHTTP ()
681+ http .StubRepoResponse ("OWNER" , "REPO" )
682+ http .StubResponse (200 , bytes .NewBufferString (`
683+ { "data": {
684+ "repository": {
685+ "description": "social distancing"
686+ }}}
687+ ` ))
688+ http .StubResponse (200 , bytes .NewBufferString (`
689+ { "name": "readme.org",
690+ "content": "IyB0cnVseSBjb29sIHJlYWRtZSBjaGVjayBpdCBvdXQ="}
691+ ` ))
692+
693+ output , err := RunCommand (repoViewCmd , "repo view" )
694+ if err != nil {
695+ t .Errorf ("error running command `repo view`: %v" , err )
696+ }
697+
698+ test .ExpectLines (t , output .String (),
699+ "OWNER/REPO" ,
700+ "social distancing" ,
701+ "# truly cool readme" ,
702+ "View this repository on GitHub: https://github.com/OWNER/REPO" )
703+ }
704+
705+ func TestRepoView_blanks (t * testing.T ) {
706+ initBlankContext ("OWNER/REPO" , "master" )
707+ http := initFakeHTTP ()
708+ http .StubRepoResponse ("OWNER" , "REPO" )
709+ http .StubResponse (200 , bytes .NewBufferString ("{}" ))
710+ http .StubResponse (200 , bytes .NewBufferString ("{}" ))
711+
712+ output , err := RunCommand (repoViewCmd , "repo view" )
713+ if err != nil {
714+ t .Errorf ("error running command `repo view`: %v" , err )
715+ }
716+
717+ test .ExpectLines (t , output .String (),
718+ "OWNER/REPO" ,
719+ "No description provided" ,
720+ "No README provided" ,
721+ "View this repository on GitHub: https://github.com/OWNER/REPO" )
722+ }
0 commit comments