diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-07 17:05:49 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-08 07:11:11 +0300 |
commit | cf8de39fc1f4b421fe529a82efc31efdfa1763a3 (patch) | |
tree | 175ce7718541ebf29777fd8ff7bca0548dd54f42 | |
parent | 94b0b06287904f0b6d1b60676d05ce2d53f653de (diff) |
localrepo: Refactor `GetRemoteReferences()` tests
As we're about to add another new option which allows the setup of
in-memory remotes, a newly added testcase will require control over the
remote that is to be queried. Refactor the tests as a preparatory test
to explicitly specify their remote.
-rw-r--r-- | internal/git/localrepo/refs_test.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/git/localrepo/refs_test.go b/internal/git/localrepo/refs_test.go index 30f8bd476..c8ac916ea 100644 --- a/internal/git/localrepo/refs_test.go +++ b/internal/git/localrepo/refs_test.go @@ -246,17 +246,20 @@ func TestRepo_GetRemoteReferences(t *testing.T) { ) for _, tc := range []struct { desc string + remote string opts []GetRemoteReferencesOption expected []git.Reference }{ { - desc: "not found", + desc: "not found", + remote: repoPath, opts: []GetRemoteReferencesOption{ WithPatterns("this-pattern-does-not-match-anything"), }, }, { - desc: "all", + desc: "all", + remote: repoPath, expected: []git.Reference{ {Name: "refs/heads/master", Target: commit}, {Name: "refs/heads/symbolic", Target: commit}, @@ -266,7 +269,8 @@ func TestRepo_GetRemoteReferences(t *testing.T) { }, }, { - desc: "branches and tags only", + desc: "branches and tags only", + remote: repoPath, opts: []GetRemoteReferencesOption{ WithPatterns("refs/heads/*", "refs/tags/*"), }, @@ -279,7 +283,7 @@ func TestRepo_GetRemoteReferences(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - refs, err := repo.GetRemoteReferences(ctx, repoPath, tc.opts...) + refs, err := repo.GetRemoteReferences(ctx, tc.remote, tc.opts...) require.NoError(t, err) require.Equal(t, tc.expected, refs) }) |