From 262c9c2b93dbb38c3353800224fd9bdaa6c0fa05 Mon Sep 17 00:00:00 2001
From: Pavel Karpy
Date: Fri, 14 Apr 2023 16:42:20 +0300
Subject: [PATCH] [#256] blobovniczaTree: Make `Exists` test stable
Corrupt and request _the same_ file.
Signed-off-by: Pavel Karpy
---
.../blobstor/blobovniczatree/exists_test.go | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go b/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go
index ff927ccbb..8d9fe526e 100644
--- a/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go
+++ b/pkg/local_object_storage/blobstor/blobovniczatree/exists_test.go
@@ -50,16 +50,15 @@ func TestExistsInvalidStorageID(t *testing.T) {
require.False(t, res.Exists)
})
- t.Run("invalid storage id", func(t *testing.T) {
- storageID := slice.Copy(putRes.StorageID)
- storageID[0] = '9'
+ t.Run("valid id but corrupted file", func(t *testing.T) {
+ relBadFileDir := filepath.Join("9", "0")
+ badFileName := "0"
// An invalid boltdb file is created so that it returns an error when opened
- badFileDir := filepath.Join(dir, "9", "0")
- require.NoError(t, os.MkdirAll(badFileDir, os.ModePerm))
- require.NoError(t, os.WriteFile(filepath.Join(badFileDir, "0"), []byte("not a boltdb file content"), 0777))
+ require.NoError(t, os.MkdirAll(filepath.Join(dir, relBadFileDir), os.ModePerm))
+ require.NoError(t, os.WriteFile(filepath.Join(dir, relBadFileDir, badFileName), []byte("not a boltdb file content"), 0777))
- res, err := b.Exists(context.Background(), common.ExistsPrm{Address: addr, StorageID: storageID})
+ res, err := b.Exists(context.Background(), common.ExistsPrm{Address: addr, StorageID: []byte(filepath.Join(relBadFileDir, badFileName))})
require.Error(t, err)
require.False(t, res.Exists)
})