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-01-18 11:47:28 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-01-19 09:51:11 +0300
commit12db0a4b3fb8f65584f25b3710da248f4c9eecaa (patch)
tree9292674e4544cb3a48f8b724d18bbcd29ea529c1
parente90c22656d4207e4f4757524547186ed549efbe3 (diff)
gittest: Remove `TestBitmapHashcache()` in favor of production code
Remove `TestBitmapHashcache()` in favor of the production-level code to read bitmaps in the git/stats package. This reduces code duplication and improves test coverage of production code.
-rw-r--r--internal/git/gittest/hashcache.go27
-rw-r--r--internal/git/objectpool/fetch_test.go8
-rw-r--r--internal/gitaly/service/repository/repack_test.go17
3 files changed, 15 insertions, 37 deletions
diff --git a/internal/git/gittest/hashcache.go b/internal/git/gittest/hashcache.go
deleted file mode 100644
index b09c58dfc..000000000
--- a/internal/git/gittest/hashcache.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package gittest
-
-import (
- "encoding/binary"
- "io"
- "os"
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
-// TestBitmapHasHashcache checks if the named pack bitmap file contains
-// "hash cache" data. See
-// https://github.com/git/git/blob/master/Documentation/technical/bitmap-format.txt
-func TestBitmapHasHashcache(t *testing.T, bitmap string) {
- bitmapFile, err := os.Open(bitmap)
- require.NoError(t, err)
- defer bitmapFile.Close()
-
- b := make([]byte, 8)
- _, err = io.ReadFull(bitmapFile, b)
- require.NoError(t, err)
-
- const hashCacheFlag = 0x4
- flags := binary.BigEndian.Uint16(b[6:])
- require.Equal(t, uint16(hashCacheFlag), flags&hashCacheFlag, "expect BITMAP_OPT_HASH_CACHE to be set")
-}
diff --git a/internal/git/objectpool/fetch_test.go b/internal/git/objectpool/fetch_test.go
index d702b5bc2..61a6ba616 100644
--- a/internal/git/objectpool/fetch_test.go
+++ b/internal/git/objectpool/fetch_test.go
@@ -140,7 +140,13 @@ func TestFetchFromOrigin_bitmapHashCache(t *testing.T) {
require.NoError(t, err)
require.Len(t, bitmaps, 1)
- gittest.TestBitmapHasHashcache(t, bitmaps[0])
+ bitmapInfo, err := stats.BitmapInfoForPath(bitmaps[0])
+ require.NoError(t, err)
+ require.Equal(t, stats.BitmapInfo{
+ Exists: true,
+ Version: 1,
+ HasHashCache: true,
+ }, bitmapInfo)
}
func TestFetchFromOrigin_refUpdates(t *testing.T) {
diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go
index f5aeda3a7..ff15e6823 100644
--- a/internal/gitaly/service/repository/repack_test.go
+++ b/internal/gitaly/service/repository/repack_test.go
@@ -223,7 +223,14 @@ func TestRepackFullSuccess(t *testing.T) {
require.NoError(t, err)
if tc.createBitmap {
require.Len(t, bitmaps, 1)
- doBitmapsContainHashCache(t, bitmaps)
+
+ bitmapInfo, err := stats.BitmapInfoForPath(bitmaps[0])
+ require.NoError(t, err)
+ require.Equal(t, stats.BitmapInfo{
+ Exists: true,
+ Version: 1,
+ HasHashCache: true,
+ }, bitmapInfo)
} else {
require.Empty(t, bitmaps)
}
@@ -254,14 +261,6 @@ func TestRepackFullCollectLogStatistics(t *testing.T) {
requireRepositoryInfoLog(t, hook.AllEntries()...)
}
-func doBitmapsContainHashCache(t *testing.T, bitmapPaths []string) {
- // for each bitmap file, check the 2-byte flag as documented in
- // https://github.com/git/git/blob/master/Documentation/technical/bitmap-format.txt
- for _, bitmapPath := range bitmapPaths {
- gittest.TestBitmapHasHashcache(t, bitmapPath)
- }
-}
-
func TestRepackFullFailure(t *testing.T) {
t.Parallel()