From 57b3744085d60cb6d151841ed485d8f75ecb4f54 Mon Sep 17 00:00:00 2001 From: Edvard Date: Fri, 12 Oct 2018 16:18:00 +0200 Subject: [PATCH] Update tend tests --- .../test_data/mocks/tend/converter.go | 13 ++++++------ .../test_data/mocks/tend/repository.go | 20 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pkg/transformers/test_data/mocks/tend/converter.go b/pkg/transformers/test_data/mocks/tend/converter.go index 77ec60c9..2669e965 100644 --- a/pkg/transformers/test_data/mocks/tend/converter.go +++ b/pkg/transformers/test_data/mocks/tend/converter.go @@ -17,20 +17,19 @@ package tend import ( "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" ) type MockTendConverter struct { - LogsToConvert []types.Log + PassedLogs []types.Log ConverterError error } -func (c *MockTendConverter) ToModels(ethLogs []types.Log) ([]tend.TendModel, error) { - c.LogsToConvert = append(c.LogsToConvert, ethLogs...) - return []tend.TendModel{test_data.TendModel}, c.ConverterError +func (converter *MockTendConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { + converter.PassedLogs = ethLogs + return []interface{}{test_data.TendModel}, converter.ConverterError } -func (c *MockTendConverter) SetConverterError(err error) { - c.ConverterError = err +func (converter *MockTendConverter) SetConverterError(err error) { + converter.ConverterError = err } diff --git a/pkg/transformers/test_data/mocks/tend/repository.go b/pkg/transformers/test_data/mocks/tend/repository.go index 6bb7da13..cfb6e9af 100644 --- a/pkg/transformers/test_data/mocks/tend/repository.go +++ b/pkg/transformers/test_data/mocks/tend/repository.go @@ -16,9 +16,9 @@ package tend import ( . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" ) type MockTendRepository struct { @@ -26,14 +26,14 @@ type MockTendRepository struct { PassedEndingBlockNumber int64 PassedHeaderID int64 PassedStartingBlockNumber int64 - PassedTendModel tend.TendModel - markHeaderCheckedErr error + PassedTendModel interface{} + markHeaderCheckedError error markHeaderCheckedPassedHeaderId int64 missingHeaders []core.Header - missingHeadersErr error + missingHeadersError error } -func (repository *MockTendRepository) Create(headerId int64, tend []tend.TendModel) error { +func (repository *MockTendRepository) Create(headerId int64, tend []interface{}) error { repository.PassedHeaderID = headerId repository.PassedTendModel = tend[0] return repository.createError @@ -44,11 +44,11 @@ func (repository *MockTendRepository) SetCreateError(err error) { } func (repository *MockTendRepository) SetMarkHeaderCheckedErr(err error) { - repository.markHeaderCheckedErr = err + repository.markHeaderCheckedError = err } func (repository *MockTendRepository) SetMissingHeadersErr(err error) { - repository.missingHeadersErr = err + repository.missingHeadersError = err } func (repository *MockTendRepository) SetMissingHeaders(headers []core.Header) { @@ -57,15 +57,17 @@ func (repository *MockTendRepository) SetMissingHeaders(headers []core.Header) { func (repository *MockTendRepository) MarkHeaderChecked(headerId int64) error { repository.markHeaderCheckedPassedHeaderId = headerId - return repository.markHeaderCheckedErr + return repository.markHeaderCheckedError } func (repository *MockTendRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { repository.PassedStartingBlockNumber = startingBlockNumber repository.PassedEndingBlockNumber = endingBlockNumber - return repository.missingHeaders, repository.missingHeadersErr + return repository.missingHeaders, repository.missingHeadersError } func (repository *MockTendRepository) AssertMarkHeaderCheckedCalledWith(headerId int64) { Expect(repository.markHeaderCheckedPassedHeaderId).To(Equal(headerId)) } + +func (repository *MockTendRepository) SetDB(db *postgres.DB) {}