[#1840] blobstor/test: Add tests for auxiliary functions

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
support/v0.34
Evgenii Stratonikov 2022-10-05 15:18:01 +03:00 committed by fyrchik
parent 328691c94f
commit 6d7ffefec5
3 changed files with 34 additions and 6 deletions

View File

@ -16,9 +16,7 @@ func TestGeneric(t *testing.T) {
defer func() { _ = os.RemoveAll(t.Name()) }()
var n int
newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
helper := func(t *testing.T, dir string) common.Storage {
return NewBlobovniczaTree(
WithLogger(zaptest.NewLogger(t)),
WithObjectSizeLimit(maxObjectSize),
@ -28,7 +26,20 @@ 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)
}
blobstortest.TestAll(t, newTree, 1024, maxObjectSize)
t.Run("info", func(t *testing.T) {
dir := filepath.Join(t.Name(), "info")
blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
return helper(t, dir)
}, Type, dir)
})
}
func TestControl(t *testing.T) {

View File

@ -13,16 +13,27 @@ import (
func TestGeneric(t *testing.T) {
defer func() { _ = os.RemoveAll(t.Name()) }()
var n int
newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
helper := func(t *testing.T, dir string) common.Storage {
return New(
WithPath(dir),
WithDepth(2),
WithDirNameLen(2))
}
var n int
newTree := func(t *testing.T) common.Storage {
dir := filepath.Join(t.Name(), strconv.Itoa(n))
return helper(t, dir)
}
blobstortest.TestAll(t, newTree, 2048, 16*1024)
t.Run("info", func(t *testing.T) {
dir := filepath.Join(t.Name(), "info")
blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
return helper(t, dir)
}, Type, dir)
})
}
func TestControl(t *testing.T) {

View File

@ -43,6 +43,12 @@ func TestAll(t *testing.T, cons Constructor, min, max uint64) {
})
}
func TestInfo(t *testing.T, cons Constructor, expectedType string, expectedPath string) {
s := cons(t)
require.Equal(t, expectedType, s.Type())
require.Equal(t, expectedPath, s.Path())
}
func prepare(t *testing.T, count int, s common.Storage, min, max uint64) []objectDesc {
objects := make([]objectDesc, count)