@@ -151,8 +151,8 @@ func TestRepoFork_in_parent_yes(t *testing.T) {
151151 }
152152
153153 expectedCmds := []string {
154- "git remote add -f fork https://github.com/someone/repo.git " ,
155- "git fetch fork " ,
154+ "git remote rename origin upstream " ,
155+ "git remote add -f origin https://github.com/someone/repo.git " ,
156156 }
157157
158158 for x , cmd := range seenCmds {
@@ -163,19 +163,19 @@ func TestRepoFork_in_parent_yes(t *testing.T) {
163163
164164 test .ExpectLines (t , output .String (),
165165 "Created fork someone/REPO" ,
166- "Remote added at fork " )
166+ "Added remote origin " )
167167}
168168
169169func TestRepoFork_outside_yes (t * testing.T ) {
170170 defer stubSince (2 * time .Second )()
171171 http := initFakeHTTP ()
172172 defer http .StubWithFixture (200 , "forkResult.json" )()
173173
174- var seenCmd * exec. Cmd
175- defer run . SetPrepareCmd ( func ( cmd * exec. Cmd ) run. Runnable {
176- seenCmd = cmd
177- return & test. OutputStub {}
178- })()
174+ cs , restore := test . InitCmdStubber ()
175+ defer restore ()
176+
177+ cs . Stub ( "" ) // git clone
178+ cs . Stub ( "" ) // git remote add
179179
180180 output , err := RunCommand (repoForkCmd , "repo fork --clone OWNER/REPO" )
181181 if err != nil {
@@ -184,7 +184,8 @@ func TestRepoFork_outside_yes(t *testing.T) {
184184
185185 eq (t , output .Stderr (), "" )
186186
187- eq (t , strings .Join (seenCmd .Args , " " ), "git clone https://github.com/someone/repo.git" )
187+ eq (t , strings .Join (cs .Calls [0 ].Args , " " ), "git clone https://github.com/someone/repo.git" )
188+ eq (t , strings .Join (cs .Calls [1 ].Args , " " ), "git -C repo remote add upstream https://github.com/OWNER/REPO.git" )
188189
189190 test .ExpectLines (t , output .String (),
190191 "Created fork someone/REPO" ,
@@ -196,11 +197,11 @@ func TestRepoFork_outside_survey_yes(t *testing.T) {
196197 http := initFakeHTTP ()
197198 defer http .StubWithFixture (200 , "forkResult.json" )()
198199
199- var seenCmd * exec. Cmd
200- defer run . SetPrepareCmd ( func ( cmd * exec. Cmd ) run. Runnable {
201- seenCmd = cmd
202- return & test. OutputStub {}
203- })()
200+ cs , restore := test . InitCmdStubber ()
201+ defer restore ()
202+
203+ cs . Stub ( "" ) // git clone
204+ cs . Stub ( "" ) // git remote add
204205
205206 oldConfirm := Confirm
206207 Confirm = func (_ string , result * bool ) error {
@@ -216,7 +217,8 @@ func TestRepoFork_outside_survey_yes(t *testing.T) {
216217
217218 eq (t , output .Stderr (), "" )
218219
219- eq (t , strings .Join (seenCmd .Args , " " ), "git clone https://github.com/someone/repo.git" )
220+ eq (t , strings .Join (cs .Calls [0 ].Args , " " ), "git clone https://github.com/someone/repo.git" )
221+ eq (t , strings .Join (cs .Calls [1 ].Args , " " ), "git -C repo remote add upstream https://github.com/OWNER/REPO.git" )
220222
221223 test .ExpectLines (t , output .String (),
222224 "Created fork someone/REPO" ,
@@ -283,8 +285,8 @@ func TestRepoFork_in_parent_survey_yes(t *testing.T) {
283285 }
284286
285287 expectedCmds := []string {
286- "git remote add -f fork https://github.com/someone/repo.git " ,
287- "git fetch fork " ,
288+ "git remote rename origin upstream " ,
289+ "git remote add -f origin https://github.com/someone/repo.git " ,
288290 }
289291
290292 for x , cmd := range seenCmds {
@@ -295,7 +297,8 @@ func TestRepoFork_in_parent_survey_yes(t *testing.T) {
295297
296298 test .ExpectLines (t , output .String (),
297299 "Created fork someone/REPO" ,
298- "Remote added at fork" )
300+ "Renamed origin remote to upstream" ,
301+ "Added remote origin" )
299302}
300303
301304func TestRepoFork_in_parent_survey_no (t * testing.T ) {
0 commit comments