[#1840] blobstor/test: Add tests for auxiliary functions
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
328691c94f
commit
6d7ffefec5
3 changed files with 34 additions and 6 deletions
|
@ -16,9 +16,7 @@ func TestGeneric(t *testing.T) {
|
||||||
|
|
||||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
defer func() { _ = os.RemoveAll(t.Name()) }()
|
||||||
|
|
||||||
var n int
|
helper := func(t *testing.T, dir string) common.Storage {
|
||||||
newTree := func(t *testing.T) common.Storage {
|
|
||||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
||||||
return NewBlobovniczaTree(
|
return NewBlobovniczaTree(
|
||||||
WithLogger(zaptest.NewLogger(t)),
|
WithLogger(zaptest.NewLogger(t)),
|
||||||
WithObjectSizeLimit(maxObjectSize),
|
WithObjectSizeLimit(maxObjectSize),
|
||||||
|
@ -28,7 +26,20 @@ func TestGeneric(t *testing.T) {
|
||||||
WithBlobovniczaSize(1<<20))
|
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)
|
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) {
|
func TestControl(t *testing.T) {
|
||||||
|
|
|
@ -13,16 +13,27 @@ import (
|
||||||
func TestGeneric(t *testing.T) {
|
func TestGeneric(t *testing.T) {
|
||||||
defer func() { _ = os.RemoveAll(t.Name()) }()
|
defer func() { _ = os.RemoveAll(t.Name()) }()
|
||||||
|
|
||||||
var n int
|
helper := func(t *testing.T, dir string) common.Storage {
|
||||||
newTree := func(t *testing.T) common.Storage {
|
|
||||||
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
||||||
return New(
|
return New(
|
||||||
WithPath(dir),
|
WithPath(dir),
|
||||||
WithDepth(2),
|
WithDepth(2),
|
||||||
WithDirNameLen(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)
|
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) {
|
func TestControl(t *testing.T) {
|
||||||
|
|
|
@ -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 {
|
func prepare(t *testing.T, count int, s common.Storage, min, max uint64) []objectDesc {
|
||||||
objects := make([]objectDesc, count)
|
objects := make([]objectDesc, count)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue