[#xx] Avoid manual management of files in tests

Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
Alejandro Lopez 2023-08-14 14:01:39 +03:00
parent 376f03a445
commit ae8be495c8
13 changed files with 17 additions and 79 deletions

View file

@ -1,9 +1,6 @@
package blobovniczatree
import (
"os"
"path/filepath"
"strconv"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
@ -15,8 +12,6 @@ import (
func TestGeneric(t *testing.T) {
const maxObjectSize = 1 << 16
defer func() { _ = os.RemoveAll(t.Name()) }()
helper := func(t *testing.T, dir string) common.Storage {
return NewBlobovniczaTree(
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
@ -27,16 +22,14 @@ func TestGeneric(t *testing.T) {
WithBlobovniczaSize(1<<20))
}
var n int
newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
return helper(t, dir)
return helper(t, t.TempDir())
}
blobstortest.TestAll(t, newTree, 1024, maxObjectSize)
t.Run("info", func(t *testing.T) {
dir := filepath.Join(t.Name(), "info")
dir := t.TempDir()
blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
return helper(t, dir)
}, Type, dir)
@ -46,17 +39,13 @@ func TestGeneric(t *testing.T) {
func TestControl(t *testing.T) {
const maxObjectSize = 2048
defer func() { _ = os.RemoveAll(t.Name()) }()
var n int
newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
return NewBlobovniczaTree(
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
WithObjectSizeLimit(maxObjectSize),
WithBlobovniczaShallowWidth(2),
WithBlobovniczaShallowDepth(2),
WithRootPath(dir),
WithRootPath(t.TempDir()),
WithBlobovniczaSize(1<<20))
}