gitutil: simplify mock with t.Cleanup (#6033)

* gitutil: simplify mock with t.Cleanup

* Scope mock to tests only
This commit is contained in:
ᴜɴᴋɴᴡᴏɴ
2020-03-29 20:15:42 +08:00
committed by GitHub
parent 933206f1fe
commit 4cbb43b860
3 changed files with 12 additions and 12 deletions

View File

@@ -24,7 +24,7 @@ func TestModuler_PullRequestMeta(t *testing.T) {
{ID: git.MustIDFromString("adfd6da3c0a3fb038393144becbf37f14f780087")},
}
mockModule := &MockModuleStore{
SetMockModuleStore(t, &MockModuleStore{
repoAddRemote: func(repoPath, name, url string, opts ...git.AddRemoteOptions) error {
if repoPath != headPath {
return fmt.Errorf("repoPath: want %q but got %q", headPath, repoPath)
@@ -93,11 +93,6 @@ func TestModuler_PullRequestMeta(t *testing.T) {
},
pullRequestMeta: Module.PullRequestMeta,
}
beforeModule := Module
Module = mockModule
t.Cleanup(func() {
Module = beforeModule
})
meta, err := Module.PullRequestMeta(headPath, basePath, headBranch, baseBranch)