2023-09-20 14:46:10 +00:00
|
|
|
package blobovniczatree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIterateSortedLeavesAndDBPathsAreSame(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
blz := NewBlobovniczaTree(
|
|
|
|
WithBlobovniczaShallowDepth(3),
|
|
|
|
WithBlobovniczaShallowWidth(5),
|
|
|
|
WithRootPath(t.TempDir()),
|
|
|
|
)
|
2023-11-27 13:01:48 +00:00
|
|
|
blz.createDBInAdvance = true
|
2023-09-20 14:46:10 +00:00
|
|
|
require.NoError(t, blz.Open(false))
|
|
|
|
require.NoError(t, blz.Init())
|
|
|
|
defer func() {
|
|
|
|
require.NoError(t, blz.Close())
|
|
|
|
}()
|
|
|
|
|
|
|
|
addr := oidtest.Address()
|
|
|
|
|
|
|
|
var leaves []string
|
|
|
|
var dbPaths []string
|
|
|
|
|
|
|
|
blz.iterateSortedLeaves(context.Background(), &addr, func(s string) (bool, error) {
|
|
|
|
leaves = append(leaves, s)
|
|
|
|
return false, nil
|
|
|
|
})
|
|
|
|
|
|
|
|
blz.iterateSortedDBPaths(context.Background(), addr, func(s string) (bool, error) {
|
|
|
|
dbPaths = append(dbPaths, s)
|
|
|
|
return false, nil
|
|
|
|
})
|
|
|
|
|
|
|
|
require.Equal(t, leaves, dbPaths)
|
|
|
|
}
|