From 2e8f6cf822666c23b7f38cb97fbcd1ccf0e39ae8 Mon Sep 17 00:00:00 2001 From: Dmytro Haidashenko Date: Wed, 15 Jan 2025 19:31:51 +0100 Subject: [PATCH] Fixed Smoke Test --- .mockery.yaml | 2 +- ...vent_loader_test.go => log_poller_test.go} | 31 +++-- pkg/solana/logpoller/filters_test.go | 28 ++--- pkg/solana/logpoller/log_poller.go | 19 ++- pkg/solana/logpoller/log_poller_test.go | 14 +-- pkg/solana/logpoller/mock_orm.go | 114 +++++++++--------- 6 files changed, 117 insertions(+), 91 deletions(-) rename integration-tests/smoke/{event_loader_test.go => log_poller_test.go} (86%) diff --git a/.mockery.yaml b/.mockery.yaml index be2ba8b88..3f81f53cc 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -59,5 +59,5 @@ packages: inpackage: True dir: "pkg/solana/logpoller" filename: mock_orm.go - mockname: mockORM + mockname: MockORM diff --git a/integration-tests/smoke/event_loader_test.go b/integration-tests/smoke/log_poller_test.go similarity index 86% rename from integration-tests/smoke/event_loader_test.go rename to integration-tests/smoke/log_poller_test.go index 2e77403d1..3f5b100a6 100644 --- a/integration-tests/smoke/event_loader_test.go +++ b/integration-tests/smoke/log_poller_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "crypto/sha256" + "database/sql" "encoding/base64" "fmt" "os" @@ -17,6 +18,7 @@ import ( "github.com/gagliardetto/solana-go/rpc" "github.com/gagliardetto/solana-go/rpc/ws" "github.com/gagliardetto/solana-go/text" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" @@ -61,15 +63,17 @@ func TestEventLoader(t *testing.T) { totalLogsToSend := 30 parser := &printParser{t: t} sender := newLogSender(t, rpcClient, wsClient) - collector := logpoller.NewEncodedLogCollector( - rpcClient, - parser, - logger.Nop(), - ) + orm := logpoller.NewMockORM(t) // TODO: replace with real DB, when available + programPubKey, err := solana.PublicKeyFromBase58(programPubKey) + require.NoError(t, err) + orm.EXPECT().SelectFilters(mock.Anything).Return([]logpoller.Filter{{IsBackfilled: false, Address: logpoller.PublicKey(programPubKey)}}, nil).Once() + orm.EXPECT().MarkFilterBackfilled(mock.Anything, mock.Anything).Return(nil).Once() + orm.EXPECT().GetLatestBlock(mock.Anything).Return(0, sql.ErrNoRows) + lp := logpoller.NewWithCustomProcessor(logger.TestSugared(t), orm, rpcClient, parser.ProcessBlocks) - require.NoError(t, collector.Start(ctx)) + require.NoError(t, lp.Start(ctx)) t.Cleanup(func() { - require.NoError(t, collector.Close()) + require.NoError(t, lp.Close()) }) go func(ctx context.Context, sender *logSender, privateKey *solana.PrivateKey) { @@ -143,7 +147,18 @@ type printParser struct { values []uint64 } -func (p *printParser) Process(block logpoller.Block) error { +func (p *printParser) ProcessBlocks(ctx context.Context, blocks []logpoller.Block) error { + for _, b := range blocks { + err := p.process(b) + if err != nil { + return err + } + } + + return nil +} + +func (p *printParser) process(block logpoller.Block) error { p.t.Helper() sum := sha256.Sum256([]byte("event:TestEvent")) diff --git a/pkg/solana/logpoller/filters_test.go b/pkg/solana/logpoller/filters_test.go index 041480dbe..9ccee2db9 100644 --- a/pkg/solana/logpoller/filters_test.go +++ b/pkg/solana/logpoller/filters_test.go @@ -16,7 +16,7 @@ import ( ) func TestFilters_LoadFilters(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(logger.Sugared(logger.Test(t)), orm) ctx := tests.Context(t) orm.On("SelectFilters", mock.Anything).Return(nil, errors.New("db failed")).Once() @@ -65,13 +65,13 @@ func TestFilters_LoadFilters(t *testing.T) { func TestFilters_RegisterFilter(t *testing.T) { lggr := logger.Sugared(logger.Test(t)) t.Run("Returns an error if name is empty", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) err := fs.RegisterFilter(tests.Context(t), Filter{}) require.EqualError(t, err, "name is required") }) t.Run("Returns an error if fails to load filters from db", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) orm.On("SelectFilters", mock.Anything).Return(nil, errors.New("db failed")).Once() err := fs.RegisterFilter(tests.Context(t), Filter{Name: "Filter"}) @@ -111,7 +111,7 @@ func TestFilters_RegisterFilter(t *testing.T) { } for _, tc := range testCases { t.Run(fmt.Sprintf("Updating %s", tc.Name), func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) const filterName = "Filter" dbFilter := Filter{Name: filterName} @@ -124,7 +124,7 @@ func TestFilters_RegisterFilter(t *testing.T) { } }) t.Run("Happy path", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) const filterName = "Filter" orm.On("SelectFilters", mock.Anything).Return(nil, nil).Once() @@ -150,7 +150,7 @@ func TestFilters_RegisterFilter(t *testing.T) { require.Equal(t, filter, storedFilters[0]) }) t.Run("Can reregister after unregister", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) const filterName = "Filter" orm.On("SelectFilters", mock.Anything).Return(nil, nil).Once() @@ -174,14 +174,14 @@ func TestFilters_RegisterFilter(t *testing.T) { func TestFilters_UnregisterFilter(t *testing.T) { lggr := logger.Sugared(logger.Test(t)) t.Run("Returns an error if fails to load filters from db", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) orm.On("SelectFilters", mock.Anything).Return(nil, errors.New("db failed")).Once() err := fs.UnregisterFilter(tests.Context(t), "Filter") require.EqualError(t, err, "failed to load filters: failed to select filters from db: db failed") }) t.Run("Noop if filter is not present", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) const filterName = "Filter" orm.On("SelectFilters", mock.Anything).Return(nil, nil).Once() @@ -189,7 +189,7 @@ func TestFilters_UnregisterFilter(t *testing.T) { require.NoError(t, err) }) t.Run("Returns error if fails to mark filter as deleted", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) const filterName = "Filter" const id int64 = 10 @@ -199,7 +199,7 @@ func TestFilters_UnregisterFilter(t *testing.T) { require.EqualError(t, err, "failed to mark filter deleted: db query failed") }) t.Run("Happy path", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) const filterName = "Filter" const id int64 = 10 @@ -217,7 +217,7 @@ func TestFilters_UnregisterFilter(t *testing.T) { func TestFilters_PruneFilters(t *testing.T) { lggr := logger.Sugared(logger.Test(t)) t.Run("Happy path", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) toDelete := Filter{ ID: 1, @@ -237,7 +237,7 @@ func TestFilters_PruneFilters(t *testing.T) { require.Len(t, fs.filtersToDelete, 0) }) t.Run("If DB removal fails will add filters back into removal slice ", func(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) fs := newFilters(lggr, orm) toDelete := Filter{ ID: 1, @@ -268,7 +268,7 @@ func TestFilters_PruneFilters(t *testing.T) { } func TestFilters_MatchingFilters(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) lggr := logger.Sugared(logger.Test(t)) expectedFilter1 := Filter{ ID: 1, @@ -310,7 +310,7 @@ func TestFilters_MatchingFilters(t *testing.T) { } func TestFilters_GetFiltersToBackfill(t *testing.T) { - orm := newMockORM(t) + orm := NewMockORM(t) lggr := logger.Sugared(logger.Test(t)) backfilledFilter := Filter{ ID: 1, diff --git a/pkg/solana/logpoller/log_poller.go b/pkg/solana/logpoller/log_poller.go index 80c184850..ada5715c8 100644 --- a/pkg/solana/logpoller/log_poller.go +++ b/pkg/solana/logpoller/log_poller.go @@ -50,6 +50,7 @@ type LogPoller struct { client RPCClient loader logsLoader filters filtersI + processBlocks func(ctx context.Context, blocks []Block) error // TODO: introduced for smoke test. Remove after NONEVM-916 is merged } func New(lggr logger.SugaredLogger, orm ORM, client RPCClient) *LogPoller { @@ -61,6 +62,8 @@ func New(lggr logger.SugaredLogger, orm ORM, client RPCClient) *LogPoller { client: client, } + lp.processBlocks = lp.processBlocksImpl + lp.Service, lp.eng = services.Config{ Name: "LogPollerService", Start: lp.start, @@ -74,6 +77,12 @@ func New(lggr logger.SugaredLogger, orm ORM, client RPCClient) *LogPoller { return lp } +func NewWithCustomProcessor(lggr logger.SugaredLogger, orm ORM, client RPCClient, processBlocks func(ctx context.Context, blocks []Block) error) *LogPoller { + lp := New(lggr, orm, client) + lp.processBlocks = processBlocks + return lp +} + func (lp *LogPoller) start(ctx context.Context) error { err := lp.filters.LoadFilters(ctx) if err != nil { @@ -204,7 +213,7 @@ func appendBuffered(ch <-chan Block, max int, blocks []Block) []Block { } } -func (lp *LogPoller) processBlocks(ctx context.Context, blocks []Block) error { +func (lp *LogPoller) processBlocksImpl(ctx context.Context, blocks []Block) error { // TODO: add logic implemented by NONEVM-916 return nil } @@ -233,10 +242,16 @@ func (lp *LogPoller) run(ctx context.Context) error { return fmt.Errorf("failed getting highest slot: %w", err) } - if lastProcessedSlot >= int64(highestSlot) { + if lastProcessedSlot > int64(highestSlot) { return fmt.Errorf("last processed slot %d is higher than highest RPC slot %d", lastProcessedSlot, highestSlot) } + if lastProcessedSlot == int64(highestSlot) { + lp.lggr.Debugw("RPC's latest finalized block is the same as latest processed - skipping", "lastProcessedSlot", lastProcessedSlot) + return nil + } + + lp.lggr.Debugw("Got new slot range to process", "from", lastProcessedSlot+1, "to", highestSlot) err = lp.processBlocksRange(ctx, addresses, lastProcessedSlot+1, int64(highestSlot)) if err != nil { return fmt.Errorf("failed processing block range [%d, %d]: %w", lastProcessedSlot+1, highestSlot, err) diff --git a/pkg/solana/logpoller/log_poller_test.go b/pkg/solana/logpoller/log_poller_test.go index bca5a8867..ac322336f 100644 --- a/pkg/solana/logpoller/log_poller_test.go +++ b/pkg/solana/logpoller/log_poller_test.go @@ -18,7 +18,7 @@ import ( ) type mockedLP struct { - ORM *mockORM + ORM *MockORM Client *mocks.RPCClient Loader *mockLogsLoader Filters *mockFilters @@ -27,18 +27,14 @@ type mockedLP struct { func newMockedLP(t *testing.T) mockedLP { mockedLP := mockedLP{ - ORM: newMockORM(t), + ORM: NewMockORM(t), Client: mocks.NewRPCClient(t), Loader: newMockLogsLoader(t), Filters: newMockFilters(t), } - mockedLP.LogPoller = &LogPoller{ - lggr: logger.TestSugared(t), - orm: mockedLP.ORM, - client: mockedLP.Client, - loader: mockedLP.Loader, - filters: mockedLP.Filters, - } + mockedLP.LogPoller = New(logger.TestSugared(t), mockedLP.ORM, mockedLP.Client) + mockedLP.LogPoller.loader = mockedLP.Loader + mockedLP.LogPoller.filters = mockedLP.Filters return mockedLP } diff --git a/pkg/solana/logpoller/mock_orm.go b/pkg/solana/logpoller/mock_orm.go index eb4f43ced..0a25f4fea 100644 --- a/pkg/solana/logpoller/mock_orm.go +++ b/pkg/solana/logpoller/mock_orm.go @@ -8,21 +8,21 @@ import ( mock "github.com/stretchr/testify/mock" ) -// mockORM is an autogenerated mock type for the ORM type -type mockORM struct { +// MockORM is an autogenerated mock type for the ORM type +type MockORM struct { mock.Mock } -type mockORM_Expecter struct { +type MockORM_Expecter struct { mock *mock.Mock } -func (_m *mockORM) EXPECT() *mockORM_Expecter { - return &mockORM_Expecter{mock: &_m.Mock} +func (_m *MockORM) EXPECT() *MockORM_Expecter { + return &MockORM_Expecter{mock: &_m.Mock} } // DeleteFilters provides a mock function with given fields: ctx, filters -func (_m *mockORM) DeleteFilters(ctx context.Context, filters map[int64]Filter) error { +func (_m *MockORM) DeleteFilters(ctx context.Context, filters map[int64]Filter) error { ret := _m.Called(ctx, filters) if len(ret) == 0 { @@ -39,37 +39,37 @@ func (_m *mockORM) DeleteFilters(ctx context.Context, filters map[int64]Filter) return r0 } -// mockORM_DeleteFilters_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteFilters' -type mockORM_DeleteFilters_Call struct { +// MockORM_DeleteFilters_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteFilters' +type MockORM_DeleteFilters_Call struct { *mock.Call } // DeleteFilters is a helper method to define mock.On call // - ctx context.Context // - filters map[int64]Filter -func (_e *mockORM_Expecter) DeleteFilters(ctx interface{}, filters interface{}) *mockORM_DeleteFilters_Call { - return &mockORM_DeleteFilters_Call{Call: _e.mock.On("DeleteFilters", ctx, filters)} +func (_e *MockORM_Expecter) DeleteFilters(ctx interface{}, filters interface{}) *MockORM_DeleteFilters_Call { + return &MockORM_DeleteFilters_Call{Call: _e.mock.On("DeleteFilters", ctx, filters)} } -func (_c *mockORM_DeleteFilters_Call) Run(run func(ctx context.Context, filters map[int64]Filter)) *mockORM_DeleteFilters_Call { +func (_c *MockORM_DeleteFilters_Call) Run(run func(ctx context.Context, filters map[int64]Filter)) *MockORM_DeleteFilters_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(map[int64]Filter)) }) return _c } -func (_c *mockORM_DeleteFilters_Call) Return(_a0 error) *mockORM_DeleteFilters_Call { +func (_c *MockORM_DeleteFilters_Call) Return(_a0 error) *MockORM_DeleteFilters_Call { _c.Call.Return(_a0) return _c } -func (_c *mockORM_DeleteFilters_Call) RunAndReturn(run func(context.Context, map[int64]Filter) error) *mockORM_DeleteFilters_Call { +func (_c *MockORM_DeleteFilters_Call) RunAndReturn(run func(context.Context, map[int64]Filter) error) *MockORM_DeleteFilters_Call { _c.Call.Return(run) return _c } // GetLatestBlock provides a mock function with given fields: ctx -func (_m *mockORM) GetLatestBlock(ctx context.Context) (int64, error) { +func (_m *MockORM) GetLatestBlock(ctx context.Context) (int64, error) { ret := _m.Called(ctx) if len(ret) == 0 { @@ -96,36 +96,36 @@ func (_m *mockORM) GetLatestBlock(ctx context.Context) (int64, error) { return r0, r1 } -// mockORM_GetLatestBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestBlock' -type mockORM_GetLatestBlock_Call struct { +// MockORM_GetLatestBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestBlock' +type MockORM_GetLatestBlock_Call struct { *mock.Call } // GetLatestBlock is a helper method to define mock.On call // - ctx context.Context -func (_e *mockORM_Expecter) GetLatestBlock(ctx interface{}) *mockORM_GetLatestBlock_Call { - return &mockORM_GetLatestBlock_Call{Call: _e.mock.On("GetLatestBlock", ctx)} +func (_e *MockORM_Expecter) GetLatestBlock(ctx interface{}) *MockORM_GetLatestBlock_Call { + return &MockORM_GetLatestBlock_Call{Call: _e.mock.On("GetLatestBlock", ctx)} } -func (_c *mockORM_GetLatestBlock_Call) Run(run func(ctx context.Context)) *mockORM_GetLatestBlock_Call { +func (_c *MockORM_GetLatestBlock_Call) Run(run func(ctx context.Context)) *MockORM_GetLatestBlock_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context)) }) return _c } -func (_c *mockORM_GetLatestBlock_Call) Return(_a0 int64, _a1 error) *mockORM_GetLatestBlock_Call { +func (_c *MockORM_GetLatestBlock_Call) Return(_a0 int64, _a1 error) *MockORM_GetLatestBlock_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockORM_GetLatestBlock_Call) RunAndReturn(run func(context.Context) (int64, error)) *mockORM_GetLatestBlock_Call { +func (_c *MockORM_GetLatestBlock_Call) RunAndReturn(run func(context.Context) (int64, error)) *MockORM_GetLatestBlock_Call { _c.Call.Return(run) return _c } // InsertFilter provides a mock function with given fields: ctx, filter -func (_m *mockORM) InsertFilter(ctx context.Context, filter Filter) (int64, error) { +func (_m *MockORM) InsertFilter(ctx context.Context, filter Filter) (int64, error) { ret := _m.Called(ctx, filter) if len(ret) == 0 { @@ -152,37 +152,37 @@ func (_m *mockORM) InsertFilter(ctx context.Context, filter Filter) (int64, erro return r0, r1 } -// mockORM_InsertFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InsertFilter' -type mockORM_InsertFilter_Call struct { +// MockORM_InsertFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InsertFilter' +type MockORM_InsertFilter_Call struct { *mock.Call } // InsertFilter is a helper method to define mock.On call // - ctx context.Context // - filter Filter -func (_e *mockORM_Expecter) InsertFilter(ctx interface{}, filter interface{}) *mockORM_InsertFilter_Call { - return &mockORM_InsertFilter_Call{Call: _e.mock.On("InsertFilter", ctx, filter)} +func (_e *MockORM_Expecter) InsertFilter(ctx interface{}, filter interface{}) *MockORM_InsertFilter_Call { + return &MockORM_InsertFilter_Call{Call: _e.mock.On("InsertFilter", ctx, filter)} } -func (_c *mockORM_InsertFilter_Call) Run(run func(ctx context.Context, filter Filter)) *mockORM_InsertFilter_Call { +func (_c *MockORM_InsertFilter_Call) Run(run func(ctx context.Context, filter Filter)) *MockORM_InsertFilter_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(Filter)) }) return _c } -func (_c *mockORM_InsertFilter_Call) Return(id int64, err error) *mockORM_InsertFilter_Call { +func (_c *MockORM_InsertFilter_Call) Return(id int64, err error) *MockORM_InsertFilter_Call { _c.Call.Return(id, err) return _c } -func (_c *mockORM_InsertFilter_Call) RunAndReturn(run func(context.Context, Filter) (int64, error)) *mockORM_InsertFilter_Call { +func (_c *MockORM_InsertFilter_Call) RunAndReturn(run func(context.Context, Filter) (int64, error)) *MockORM_InsertFilter_Call { _c.Call.Return(run) return _c } // MarkFilterBackfilled provides a mock function with given fields: ctx, id -func (_m *mockORM) MarkFilterBackfilled(ctx context.Context, id int64) error { +func (_m *MockORM) MarkFilterBackfilled(ctx context.Context, id int64) error { ret := _m.Called(ctx, id) if len(ret) == 0 { @@ -199,37 +199,37 @@ func (_m *mockORM) MarkFilterBackfilled(ctx context.Context, id int64) error { return r0 } -// mockORM_MarkFilterBackfilled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MarkFilterBackfilled' -type mockORM_MarkFilterBackfilled_Call struct { +// MockORM_MarkFilterBackfilled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MarkFilterBackfilled' +type MockORM_MarkFilterBackfilled_Call struct { *mock.Call } // MarkFilterBackfilled is a helper method to define mock.On call // - ctx context.Context // - id int64 -func (_e *mockORM_Expecter) MarkFilterBackfilled(ctx interface{}, id interface{}) *mockORM_MarkFilterBackfilled_Call { - return &mockORM_MarkFilterBackfilled_Call{Call: _e.mock.On("MarkFilterBackfilled", ctx, id)} +func (_e *MockORM_Expecter) MarkFilterBackfilled(ctx interface{}, id interface{}) *MockORM_MarkFilterBackfilled_Call { + return &MockORM_MarkFilterBackfilled_Call{Call: _e.mock.On("MarkFilterBackfilled", ctx, id)} } -func (_c *mockORM_MarkFilterBackfilled_Call) Run(run func(ctx context.Context, id int64)) *mockORM_MarkFilterBackfilled_Call { +func (_c *MockORM_MarkFilterBackfilled_Call) Run(run func(ctx context.Context, id int64)) *MockORM_MarkFilterBackfilled_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(int64)) }) return _c } -func (_c *mockORM_MarkFilterBackfilled_Call) Return(err error) *mockORM_MarkFilterBackfilled_Call { +func (_c *MockORM_MarkFilterBackfilled_Call) Return(err error) *MockORM_MarkFilterBackfilled_Call { _c.Call.Return(err) return _c } -func (_c *mockORM_MarkFilterBackfilled_Call) RunAndReturn(run func(context.Context, int64) error) *mockORM_MarkFilterBackfilled_Call { +func (_c *MockORM_MarkFilterBackfilled_Call) RunAndReturn(run func(context.Context, int64) error) *MockORM_MarkFilterBackfilled_Call { _c.Call.Return(run) return _c } // MarkFilterDeleted provides a mock function with given fields: ctx, id -func (_m *mockORM) MarkFilterDeleted(ctx context.Context, id int64) error { +func (_m *MockORM) MarkFilterDeleted(ctx context.Context, id int64) error { ret := _m.Called(ctx, id) if len(ret) == 0 { @@ -246,37 +246,37 @@ func (_m *mockORM) MarkFilterDeleted(ctx context.Context, id int64) error { return r0 } -// mockORM_MarkFilterDeleted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MarkFilterDeleted' -type mockORM_MarkFilterDeleted_Call struct { +// MockORM_MarkFilterDeleted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MarkFilterDeleted' +type MockORM_MarkFilterDeleted_Call struct { *mock.Call } // MarkFilterDeleted is a helper method to define mock.On call // - ctx context.Context // - id int64 -func (_e *mockORM_Expecter) MarkFilterDeleted(ctx interface{}, id interface{}) *mockORM_MarkFilterDeleted_Call { - return &mockORM_MarkFilterDeleted_Call{Call: _e.mock.On("MarkFilterDeleted", ctx, id)} +func (_e *MockORM_Expecter) MarkFilterDeleted(ctx interface{}, id interface{}) *MockORM_MarkFilterDeleted_Call { + return &MockORM_MarkFilterDeleted_Call{Call: _e.mock.On("MarkFilterDeleted", ctx, id)} } -func (_c *mockORM_MarkFilterDeleted_Call) Run(run func(ctx context.Context, id int64)) *mockORM_MarkFilterDeleted_Call { +func (_c *MockORM_MarkFilterDeleted_Call) Run(run func(ctx context.Context, id int64)) *MockORM_MarkFilterDeleted_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context), args[1].(int64)) }) return _c } -func (_c *mockORM_MarkFilterDeleted_Call) Return(err error) *mockORM_MarkFilterDeleted_Call { +func (_c *MockORM_MarkFilterDeleted_Call) Return(err error) *MockORM_MarkFilterDeleted_Call { _c.Call.Return(err) return _c } -func (_c *mockORM_MarkFilterDeleted_Call) RunAndReturn(run func(context.Context, int64) error) *mockORM_MarkFilterDeleted_Call { +func (_c *MockORM_MarkFilterDeleted_Call) RunAndReturn(run func(context.Context, int64) error) *MockORM_MarkFilterDeleted_Call { _c.Call.Return(run) return _c } // SelectFilters provides a mock function with given fields: ctx -func (_m *mockORM) SelectFilters(ctx context.Context) ([]Filter, error) { +func (_m *MockORM) SelectFilters(ctx context.Context) ([]Filter, error) { ret := _m.Called(ctx) if len(ret) == 0 { @@ -305,41 +305,41 @@ func (_m *mockORM) SelectFilters(ctx context.Context) ([]Filter, error) { return r0, r1 } -// mockORM_SelectFilters_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SelectFilters' -type mockORM_SelectFilters_Call struct { +// MockORM_SelectFilters_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SelectFilters' +type MockORM_SelectFilters_Call struct { *mock.Call } // SelectFilters is a helper method to define mock.On call // - ctx context.Context -func (_e *mockORM_Expecter) SelectFilters(ctx interface{}) *mockORM_SelectFilters_Call { - return &mockORM_SelectFilters_Call{Call: _e.mock.On("SelectFilters", ctx)} +func (_e *MockORM_Expecter) SelectFilters(ctx interface{}) *MockORM_SelectFilters_Call { + return &MockORM_SelectFilters_Call{Call: _e.mock.On("SelectFilters", ctx)} } -func (_c *mockORM_SelectFilters_Call) Run(run func(ctx context.Context)) *mockORM_SelectFilters_Call { +func (_c *MockORM_SelectFilters_Call) Run(run func(ctx context.Context)) *MockORM_SelectFilters_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(context.Context)) }) return _c } -func (_c *mockORM_SelectFilters_Call) Return(_a0 []Filter, _a1 error) *mockORM_SelectFilters_Call { +func (_c *MockORM_SelectFilters_Call) Return(_a0 []Filter, _a1 error) *MockORM_SelectFilters_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockORM_SelectFilters_Call) RunAndReturn(run func(context.Context) ([]Filter, error)) *mockORM_SelectFilters_Call { +func (_c *MockORM_SelectFilters_Call) RunAndReturn(run func(context.Context) ([]Filter, error)) *MockORM_SelectFilters_Call { _c.Call.Return(run) return _c } -// newMockORM creates a new instance of mockORM. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockORM creates a new instance of MockORM. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func newMockORM(t interface { +func NewMockORM(t interface { mock.TestingT Cleanup(func()) -}) *mockORM { - mock := &mockORM{} +}) *MockORM { + mock := &MockORM{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) })