mockprovider

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2021 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockLoader

type MockLoader struct {
	MockName   string
	Content    []map[string]string
	CurrentRow int
	ErrorClose error
	ErrorLoad  error
}

MockLoader specifc state for database Saver provider.

func (*MockLoader) Close

func (ml *MockLoader) Close(log *logrus.Entry) error

Close closes the datasource.

func (*MockLoader) Load

func (ml *MockLoader) Load(log *logrus.Entry) (types.Record, error)

Load reads the next record and return it.

func (*MockLoader) Name

func (ml *MockLoader) Name() string

Name give the name of the destination.

func (*MockLoader) Next

func (ml *MockLoader) Next() bool

Next moves to next record and return false if there is no more records.

type MockProvider

type MockProvider struct {
	ErrorLoader   error
	LoaderToFail  int
	CurrentLoader int
	ErrorSaver    error
	SaverToFail   int
	CurrentSaver  int
	Loader        *MockLoader
	Savers        []*MockSaver
}

MockProvider implement the Provider interface with mocked actions.

func (*MockProvider) NewLoader

func (p *MockProvider) NewLoader(ctx context.Context, log *logrus.Entry, ds datasource.Datasourcer, table string, where string) (provider.Loader, error)

NewLoader analyze the datasource and return mock object implementing Loader.

func (*MockProvider) NewSaver

func (p *MockProvider) NewSaver(ctx context.Context, log *logrus.Entry, ds datasource.Datasourcer, table string, key string, mode string) (provider.Saver, error)

NewSaver analyze the datasource and return mock object implementing Saver.

type MockSaver

type MockSaver struct {
	MockName   string
	Content    []map[string]string
	ErrorClose error
	ErrorReset error
	ErrorSave  error
}

MockSaver specifc state for database Saver provider.

func (*MockSaver) Close

func (ms *MockSaver) Close(log *logrus.Entry) error

Close closes the destination.

func (*MockSaver) Name

func (ms *MockSaver) Name() string

Name give the name of the destination.

func (*MockSaver) Reset

func (ms *MockSaver) Reset(log *logrus.Entry) error

Reset reinitialize the destination (if possible).

func (*MockSaver) Save

func (ms *MockSaver) Save(log *logrus.Entry, record types.Record) error

Save writes the record to the destination.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL