Update tend tests
This commit is contained in:
parent
a4df8f348d
commit
57b3744085
@ -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
|
||||
}
|
||||
|
@ -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) {}
|
||||
|
Loading…
Reference in New Issue
Block a user