diff --git a/git/git_test.go b/git/git_test.go index a432f74b5..16bf7218e 100644 --- a/git/git_test.go +++ b/git/git_test.go @@ -3,12 +3,10 @@ package git import ( "os/exec" "reflect" - "strings" "testing" "github.com/cli/cli/internal/run" "github.com/cli/cli/test" - "github.com/stretchr/testify/assert" ) func Test_UncommittedChangeCount(t *testing.T) { @@ -199,18 +197,15 @@ func TestAddUpstreamRemote(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cs, restore := test.InitCmdStubber() - defer restore() + cs, cmdTeardown := run.Stub() + defer cmdTeardown(t) - cs.Stub("") // git remote add -f + cs.Register(tt.want, 0, "") err := AddUpstreamRemote(tt.upstreamURL, tt.cloneDir, tt.branches) if err != nil { t.Fatalf("error running command `git remote add -f`: %v", err) } - - assert.Equal(t, 1, cs.Count) - assert.Equal(t, tt.want, strings.Join(cs.Calls[0].Args, " ")) }) } } diff --git a/pkg/cmd/repo/clone/clone_test.go b/pkg/cmd/repo/clone/clone_test.go index 916c94304..7647ca4c0 100644 --- a/pkg/cmd/repo/clone/clone_test.go +++ b/pkg/cmd/repo/clone/clone_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/cli/cli/internal/config" + "github.com/cli/cli/internal/run" "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/iostreams" @@ -228,19 +229,16 @@ func Test_RepoClone_hasParent(t *testing.T) { httpClient := &http.Client{Transport: reg} - cs, restore := test.InitCmdStubber() - defer restore() + cs, cmdTeardown := run.Stub() + defer cmdTeardown(t) - cs.Stub("") // git clone - cs.Stub("") // git remote add + cs.Register(`git clone https://github.com/OWNER/REPO.git`, 0, "") + cs.Register(`git -C REPO remote add -t master -f upstream https://github.com/hubot/ORIG.git`, 0, "") _, err := runCloneCommand(httpClient, "OWNER/REPO") if err != nil { t.Fatalf("error running command `repo clone`: %v", err) } - - assert.Equal(t, 2, cs.Count) - assert.Equal(t, "git -C REPO remote add -t master -f upstream https://github.com/hubot/ORIG.git", strings.Join(cs.Calls[1].Args, " ")) } func Test_RepoClone_withoutUsername(t *testing.T) {