Update tend tests

This commit is contained in:
Edvard 2018-10-12 16:18:00 +02:00
parent a4df8f348d
commit 57b3744085
2 changed files with 17 additions and 16 deletions

View File

@ -17,20 +17,19 @@ package tend
import ( import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
) )
type MockTendConverter struct { type MockTendConverter struct {
LogsToConvert []types.Log PassedLogs []types.Log
ConverterError error ConverterError error
} }
func (c *MockTendConverter) ToModels(ethLogs []types.Log) ([]tend.TendModel, error) { func (converter *MockTendConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
c.LogsToConvert = append(c.LogsToConvert, ethLogs...) converter.PassedLogs = ethLogs
return []tend.TendModel{test_data.TendModel}, c.ConverterError return []interface{}{test_data.TendModel}, converter.ConverterError
} }
func (c *MockTendConverter) SetConverterError(err error) { func (converter *MockTendConverter) SetConverterError(err error) {
c.ConverterError = err converter.ConverterError = err
} }

View File

@ -16,9 +16,9 @@ package tend
import ( import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
) )
type MockTendRepository struct { type MockTendRepository struct {
@ -26,14 +26,14 @@ type MockTendRepository struct {
PassedEndingBlockNumber int64 PassedEndingBlockNumber int64
PassedHeaderID int64 PassedHeaderID int64
PassedStartingBlockNumber int64 PassedStartingBlockNumber int64
PassedTendModel tend.TendModel PassedTendModel interface{}
markHeaderCheckedErr error markHeaderCheckedError error
markHeaderCheckedPassedHeaderId int64 markHeaderCheckedPassedHeaderId int64
missingHeaders []core.Header 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.PassedHeaderID = headerId
repository.PassedTendModel = tend[0] repository.PassedTendModel = tend[0]
return repository.createError return repository.createError
@ -44,11 +44,11 @@ func (repository *MockTendRepository) SetCreateError(err error) {
} }
func (repository *MockTendRepository) SetMarkHeaderCheckedErr(err error) { func (repository *MockTendRepository) SetMarkHeaderCheckedErr(err error) {
repository.markHeaderCheckedErr = err repository.markHeaderCheckedError = err
} }
func (repository *MockTendRepository) SetMissingHeadersErr(err error) { func (repository *MockTendRepository) SetMissingHeadersErr(err error) {
repository.missingHeadersErr = err repository.missingHeadersError = err
} }
func (repository *MockTendRepository) SetMissingHeaders(headers []core.Header) { 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 { func (repository *MockTendRepository) MarkHeaderChecked(headerId int64) error {
repository.markHeaderCheckedPassedHeaderId = headerId repository.markHeaderCheckedPassedHeaderId = headerId
return repository.markHeaderCheckedErr return repository.markHeaderCheckedError
} }
func (repository *MockTendRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { func (repository *MockTendRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr return repository.missingHeaders, repository.missingHeadersError
} }
func (repository *MockTendRepository) AssertMarkHeaderCheckedCalledWith(headerId int64) { func (repository *MockTendRepository) AssertMarkHeaderCheckedCalledWith(headerId int64) {
Expect(repository.markHeaderCheckedPassedHeaderId).To(Equal(headerId)) Expect(repository.markHeaderCheckedPassedHeaderId).To(Equal(headerId))
} }
func (repository *MockTendRepository) SetDB(db *postgres.DB) {}