From 8273a3dfb26665bd4f29d0d3aad6c7e6c44f1c8c Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 30 Mar 2023 13:15:29 +0300 Subject: [PATCH] [#188] blobstor: Refactor blobstor test Resolve funlen linter for TestIterate function Signed-off-by: Dmitrii Stepanov --- .../blobstor/internal/blobstortest/iterate.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go b/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go index e2a310ef..f98cca63 100644 --- a/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go +++ b/pkg/local_object_storage/blobstor/internal/blobstortest/iterate.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" ) -// nolint: funlen func TestIterate(t *testing.T, cons Constructor, min, max uint64) { s := cons(t) require.NoError(t, s.Open(false)) @@ -28,6 +27,14 @@ func TestIterate(t *testing.T, cons Constructor, min, max uint64) { objects = append(objects[:delID], objects[delID+1:]...) + runTestNormalHandler(t, s, objects) + + runTestLazyHandler(t, s, objects) + + runTestIgnoreLogicalErrors(t, s, objects) +} + +func runTestNormalHandler(t *testing.T, s common.Storage, objects []objectDesc) { t.Run("normal handler", func(t *testing.T) { seen := make(map[string]objectDesc) @@ -52,7 +59,9 @@ func TestIterate(t *testing.T, cons Constructor, min, max uint64) { require.Equal(t, objects[i].storageID, d.storageID) } }) +} +func runTestLazyHandler(t *testing.T, s common.Storage, objects []objectDesc) { t.Run("lazy handler", func(t *testing.T) { seen := make(map[string]func() ([]byte, error)) @@ -74,7 +83,9 @@ func TestIterate(t *testing.T, cons Constructor, min, max uint64) { require.Equal(t, objects[i].raw, data) } }) +} +func runTestIgnoreLogicalErrors(t *testing.T, s common.Storage, objects []objectDesc) { t.Run("ignore errors doesn't work for logical errors", func(t *testing.T) { seen := make(map[string]objectDesc)