Skip to content

Commit

Permalink
Remove unused mem block adapter from settings manager test (#7239)
Browse files Browse the repository at this point in the history
It was created but never actually used.
  • Loading branch information
arielshaqed authored Jan 4, 2024
1 parent 88247ac commit deeb64e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/graveler/settings/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"github.com/go-test/deep"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/treeverse/lakefs/pkg/block"
"github.com/treeverse/lakefs/pkg/block/mem"
"github.com/treeverse/lakefs/pkg/cache"
"github.com/treeverse/lakefs/pkg/graveler"
"github.com/treeverse/lakefs/pkg/graveler/mock"
Expand Down Expand Up @@ -44,7 +42,7 @@ func (m *mockCache) GetOrSet(k interface{}, setFn cache.SetFn) (v interface{}, e

func TestNonExistent(t *testing.T) {
ctx := context.Background()
m, _ := prepareTest(t, ctx, nil, nil)
m := prepareTest(t, ctx, nil, nil)
setting := &settings.ExampleSettings{}
err := m.Get(ctx, repository, "settingKey", setting)
require.NoError(t, err)
Expand All @@ -60,7 +58,7 @@ func TestSaveAndGet(t *testing.T) {
mc := &mockCache{
c: make(map[interface{}]interface{}),
}
m, _ := prepareTest(t, ctx, mc, nil)
m := prepareTest(t, ctx, mc, nil)
firstSettings := newSetting(5, 6, "hello")
err := m.Save(ctx, repository, "settingKey", firstSettings, nil)
testutil.Must(t, err)
Expand Down Expand Up @@ -92,7 +90,7 @@ func TestSaveAndGet(t *testing.T) {

func TestGetLatest(t *testing.T) {
ctx := context.Background()
m, _ := prepareTest(t, ctx, nil, nil)
m := prepareTest(t, ctx, nil, nil)
err := m.Save(ctx, repository, "settingKey", newSetting(5, 6, "hello"), nil)
testutil.Must(t, err)
setting := &settings.ExampleSettings{}
Expand All @@ -111,7 +109,7 @@ func TestConditionalUpdate(t *testing.T) {
mc := &mockCache{
c: make(map[interface{}]interface{}),
}
m, _ := prepareTest(t, ctx, mc, nil)
m := prepareTest(t, ctx, mc, nil)
firstSettings := newSetting(5, 6, "hello")
err := m.Save(ctx, repository, "settingKey", firstSettings, swag.String("WRONG_CHECKSUM"))
require.ErrorIs(t, err, graveler.ErrPreconditionFailed)
Expand All @@ -130,11 +128,10 @@ func TestConditionalUpdate(t *testing.T) {
require.ErrorIs(t, err, graveler.ErrPreconditionFailed)
}

func prepareTest(t *testing.T, ctx context.Context, refCache cache.Cache, branchLockCallback func(context.Context, *graveler.RepositoryRecord, graveler.BranchID, func() (interface{}, error)) (interface{}, error)) (*settings.Manager, block.Adapter) {
func prepareTest(t *testing.T, ctx context.Context, refCache cache.Cache, branchLockCallback func(context.Context, *graveler.RepositoryRecord, graveler.BranchID, func() (interface{}, error)) (interface{}, error)) *settings.Manager {
ctrl := gomock.NewController(t)
refManager := mock.NewMockRefManager(ctrl)

blockAdapter := mem.New(context.Background())
branchLock := mock.NewMockBranchLocker(ctrl)
cb := func(_ context.Context, _ *graveler.RepositoryRecord, _ graveler.BranchID, f func() (interface{}, error)) (interface{}, error) {
return f()
Expand All @@ -152,7 +149,7 @@ func prepareTest(t *testing.T, ctx context.Context, refCache cache.Cache, branch
m := settings.NewManager(refManager, kvStore, opts...)

refManager.EXPECT().GetRepository(ctx, gomock.Eq(repository.RepositoryID)).AnyTimes().Return(repository, nil)
return m, blockAdapter
return m
}

func newSetting(a int32, b int32, c string) *settings.ExampleSettings {
Expand Down

0 comments on commit deeb64e

Please sign in to comment.