@@ -40,6 +40,31 @@ func TestRepoFork_already_forked(t *testing.T) {
4040 }
4141}
4242
43+ func TestRepoFork_reuseRemote (t * testing.T ) {
44+ initContext = func () context.Context {
45+ ctx := context .NewBlank ()
46+ ctx .SetBaseRepo ("OWNER/REPO" )
47+ ctx .SetBranch ("master" )
48+ ctx .SetRemotes (map [string ]string {
49+ "upstream" : "OWNER/REPO" ,
50+ "origin" : "someone/REPO" ,
51+ })
52+ return ctx
53+ }
54+ http := initFakeHTTP ()
55+ http .StubRepoResponse ("OWNER" , "REPO" )
56+ defer http .StubWithFixture (200 , "forkResult.json" )()
57+
58+ output , err := RunCommand (repoForkCmd , "repo fork" )
59+ if err != nil {
60+ t .Errorf ("got unexpected error: %v" , err )
61+ }
62+ if ! strings .Contains (output .String (), "Using existing remote origin" ) {
63+ t .Errorf ("output did not match: %q" , output )
64+ return
65+ }
66+ }
67+
4368func stubSince (d time.Duration ) func () {
4469 originalSince := Since
4570 Since = func (t time.Time ) time.Duration {
@@ -579,7 +604,6 @@ func TestRepoCreate_orgWithTeam(t *testing.T) {
579604 }
580605}
581606
582-
583607func TestRepoView (t * testing.T ) {
584608 initBlankContext ("OWNER/REPO" , "master" )
585609 http := initFakeHTTP ()
0 commit comments