Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-06 10:21:20 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-06 10:29:41 +0300
commit9887732f783fd7b558452e2d37d1d621b1f3ea2b (patch)
treebcfc47fb5a4cd2a8fe0e5cc2f897cc503e46fa22
parent840770d99db444911159368ca15cf6fda727c1a6 (diff)
tests: Convert some tests to use new helpers that read refs
Convert some of our tests that read references to use the new helpers `gittest.GetReferences()` and `gittest.GetSymbolicRef()`.
-rw-r--r--internal/git/updateref/updateref_test.go12
-rw-r--r--internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go7
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go3
-rw-r--r--internal/gitaly/service/repository/create_repository_from_bundle_test.go8
4 files changed, 8 insertions, 22 deletions
diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go
index d542c992c..b6654fd94 100644
--- a/internal/git/updateref/updateref_test.go
+++ b/internal/git/updateref/updateref_test.go
@@ -371,15 +371,13 @@ func TestUpdater_invalidStateTransitions(t *testing.T) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
- _, repo, _, updater := setupUpdater(t, ctx)
+ cfg, _, repoPath, updater := setupUpdater(t, ctx)
defer func() { require.Equal(t, tc.expectedErr, updater.Close()) }()
require.Equal(t, tc.expectedErr, tc.perform(t, updater))
// Verify no references were created.
- refs, err := repo.GetReferences(ctx)
- require.NoError(t, err)
- require.Empty(t, refs)
+ require.Empty(t, gittest.GetReferences(t, cfg, repoPath))
})
}
}
@@ -574,7 +572,7 @@ func TestUpdater_bulkOperation(t *testing.T) {
ctx := testhelper.Context(t)
- cfg, repo, repoPath, updater := setupUpdater(t, ctx)
+ cfg, _, repoPath, updater := setupUpdater(t, ctx)
defer testhelper.MustClose(t, updater)
commitID := gittest.WriteCommit(t, cfg, repoPath)
@@ -596,9 +594,7 @@ func TestUpdater_bulkOperation(t *testing.T) {
require.NoError(t, updater.Commit())
}
- refs, err := repo.GetReferences(ctx, "refs/")
- require.NoError(t, err)
- require.ElementsMatch(t, expectedRefs, refs)
+ require.ElementsMatch(t, expectedRefs, gittest.GetReferences(t, cfg, repoPath))
}
func TestUpdater_contextCancellation(t *testing.T) {
diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
index 235ca49c2..21ed96b6d 100644
--- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
+++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
@@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
@@ -27,8 +26,6 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
testcfg.BuildGitalyHooks(t, cfg)
- repo := localrepo.NewTestRepo(t, cfg, protoRepo)
-
blobID := gittest.WriteBlob(t, cfg, repoPath, []byte("blob contents"))
commitID := gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"), gittest.WithTreeEntries(
gittest.TreeEntry{Path: "blob", Mode: "100644", OID: blobID},
@@ -78,9 +75,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
require.NoError(t, err)
// Ensure that the internal refs are gone, but the others still exist
- refs, err := repo.GetReferences(ctx, "refs/")
- require.NoError(t, err)
-
+ refs := gittest.GetReferences(t, cfg, repoPath)
refNames := make([]string, len(refs))
for i, branch := range refs {
refNames[i] = branch.Name.String()
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index ccd53fb3c..61fbcae3c 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -76,8 +76,7 @@ func TestDeleteRefs_successful(t *testing.T) {
require.NoError(t, err)
// Ensure that the internal refs are gone, but the others still exist
- refs, err := localrepo.NewTestRepo(t, cfg, repo).GetReferences(ctx, "refs/")
- require.NoError(t, err)
+ refs := gittest.GetReferences(t, cfg, repoPath)
refNames := make([]string, len(refs))
for i, branch := range refs {
diff --git a/internal/gitaly/service/repository/create_repository_from_bundle_test.go b/internal/gitaly/service/repository/create_repository_from_bundle_test.go
index 32c65c826..59692b3af 100644
--- a/internal/gitaly/service/repository/create_repository_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_bundle_test.go
@@ -156,12 +156,8 @@ func TestCreateRepositoryFromBundle(t *testing.T) {
// Verify connectivity and validity of the repository objects.
gittest.Exec(t, cfg, "-C", repoPath, "fsck")
- refs, err := repo.GetReferences(ctx)
- require.NoError(t, err)
-
- headRef, err := repo.HeadReference(ctx)
- require.NoError(t, err)
- head := git.NewSymbolicReference("HEAD", headRef)
+ refs := gittest.GetReferences(t, cfg, repoPath)
+ head := gittest.GetSymbolicRef(t, cfg, repoPath, "HEAD")
// Verify repository contains references from the bundle.
require.ElementsMatch(t, setup.expectedRefs, append(refs, head))