[#139] Refactor blobovnicza exist test to not use chmod

Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
Alejandro Lopez 2023-04-14 12:16:14 +03:00
parent adcfce39cf
commit 41eb3129ae
3 changed files with 7 additions and 6 deletions

View file

@ -53,10 +53,11 @@ func TestExistsInvalidStorageID(t *testing.T) {
t.Run("invalid storage id", func(t *testing.T) {
storageID := slice.Copy(putRes.StorageID)
storageID[0] = '9'
badDir := filepath.Join(dir, "9")
require.NoError(t, os.MkdirAll(badDir, os.ModePerm))
require.NoError(t, os.Chmod(badDir, 0))
t.Cleanup(func() { _ = os.Chmod(filepath.Join(dir, "9"), os.ModePerm) })
// 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))
res, err := b.Exists(context.Background(), common.ExistsPrm{Address: addr, StorageID: storageID})
require.Error(t, err)