From ea0e8d5c23501c6e62915e70f17e8c87a6f33858 Mon Sep 17 00:00:00 2001 From: Parth Patel Date: Tue, 26 Oct 2021 11:38:12 -0400 Subject: [PATCH] fixed http_tests git stub --- pkg/cmd/repo/rename/http_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/repo/rename/http_test.go b/pkg/cmd/repo/rename/http_test.go index 56e8dc365..eac25f97e 100644 --- a/pkg/cmd/repo/rename/http_test.go +++ b/pkg/cmd/repo/rename/http_test.go @@ -38,7 +38,7 @@ func TestRenameRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, execStubs: func(cs *run.CommandStubber) { - cs.Register(`git remote set-url origin https://github.com/OWNER/REPO.git`, 0, "") + cs.Register(`git remote set-url origin https://github.com/OWNER/NEW_REPO.git`, 0, "") }, tty: true, }, @@ -59,7 +59,7 @@ func TestRenameRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, execStubs: func(cs *run.CommandStubber) { - cs.Register(`git remote set-url origin https://github.com/OWNER/REPO.git`, 0, "") + cs.Register(`git remote set-url origin https://github.com/OWNER/NEW_REPO.git`, 0, "") }, tty: true, }, @@ -79,7 +79,7 @@ func TestRenameRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, execStubs: func(cs *run.CommandStubber) { - cs.Register(`git remote set-url origin https://github.com/OWNER/REPO.git`, 0, "") + cs.Register(`git remote set-url origin https://github.com/OWNER/NEW_REPO.git`, 0, "") }, }, { @@ -97,7 +97,7 @@ func TestRenameRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, execStubs: func(cs *run.CommandStubber) { - cs.Register(`git remote set-url origin https://github.com/OWNER/REPO.git`, 0, "") + cs.Register(`git remote set-url origin https://github.com/OWNER/NEW_REPO.git`, 0, "") }, tty: true, }, @@ -107,7 +107,7 @@ func TestRenameRun(t *testing.T) { BaseRepo: func() (ghrepo.Interface, error) { return ghrepo.New("OWNER", "REPO"), nil }, - newRepoSelector: "REPO", + newRepoSelector: "NEW_REPO", }, httpStubs: func(reg *httpmock.Registry) { reg.Register( @@ -115,7 +115,7 @@ func TestRenameRun(t *testing.T) { httpmock.StatusStringResponse(204, "{}")) }, execStubs: func(cs *run.CommandStubber) { - cs.Register(`git remote set-url origin https://github.com/OWNER/REPO.git`, 0, "") + cs.Register(`git remote set-url origin https://github.com/OWNER/NEW_REPO.git`, 0, "") }, }, } @@ -145,6 +145,12 @@ func TestRenameRun(t *testing.T) { }, nil } + cs, restoreRun := run.Stub() + defer restoreRun(t) + if tt.execStubs != nil { + tt.execStubs(cs) + } + reg := &httpmock.Registry{} if tt.httpStubs != nil { tt.httpStubs(reg)