Documentation
¶
Overview ¶
Package testing is a test suit for readers. They should provide an object that implements the Constructor interface then run:
import reader_test "github.com/arsham/expipe/reader/testing" .... r, err := reader_test.New(reader.SetName("test")) if err != nil { panic(err) } c := &Construct{r} reader_test.TestSuites(t, c)
The test suit will pick it up and does all the tests.
Important Note ¶
You need to write the edge cases if they are not covered in this section.
Index ¶
- func TestSuites(t *testing.T, cons Constructor)
- type Conf
- type Config
- func (c *Config) Backoff() int
- func (c *Config) Endpoint() string
- func (c *Config) Interval() time.Duration
- func (c *Config) Logger() internal.FieldLogger
- func (c *Config) Name() string
- func (c *Config) NewInstance() (reader.DataReader, error)
- func (c *Config) Timeout() time.Duration
- func (c *Config) TypeName() string
- type Constructor
- type Reader
- func (r *Reader) Backoff() int
- func (r *Reader) Endpoint() string
- func (r *Reader) Interval() time.Duration
- func (r *Reader) Logger() internal.FieldLogger
- func (r *Reader) Mapper() datatype.Mapper
- func (r *Reader) Name() string
- func (r *Reader) Ping() error
- func (r *Reader) Read(job *token.Context) (*reader.Result, error)
- func (r *Reader) SetBackoff(backoff int)
- func (r *Reader) SetEndpoint(endpoint string)
- func (r *Reader) SetInterval(interval time.Duration)
- func (r *Reader) SetLogger(log internal.FieldLogger)
- func (r *Reader) SetMapper(mapper datatype.Mapper)
- func (r *Reader) SetName(name string)
- func (r *Reader) SetTimeout(timeout time.Duration)
- func (r *Reader) SetTypeName(typeName string)
- func (r *Reader) Timeout() time.Duration
- func (r *Reader) TypeName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestSuites ¶ added in v0.8.1
func TestSuites(t *testing.T, cons Constructor)
TestSuites returns a map of test name to the runner function.
Types ¶
type Conf ¶ added in v0.9.1
Conf func is used for initializing a Config object.
func WithBackoff ¶ added in v0.9.1
WithBackoff doesn't produce any errors.
func WithEndpoint ¶ added in v0.9.1
WithEndpoint doesn't produce any errors.
func WithInterval ¶ added in v0.9.1
WithInterval doesn't produce any errors.
func WithLogger ¶ added in v0.9.1
func WithLogger(log internal.FieldLogger) Conf
WithLogger doesn't produce any errors.
func WithTimeout ¶ added in v0.9.1
WithTimeout doesn't produce any errors.
func WithTypeName ¶ added in v0.9.1
WithTypeName doesn't produce any errors.
type Config ¶ added in v0.7.0
type Config struct { MockName string MockTypeName string MockEndpoint string MockTimeout time.Duration MockInterval time.Duration MockBackoff int MockLogger internal.FieldLogger }
Config is used for instantiating a mock reader
func (*Config) Logger ¶ added in v0.7.0
func (c *Config) Logger() internal.FieldLogger
Logger returns the logger
func (*Config) NewInstance ¶ added in v0.7.0
func (c *Config) NewInstance() (reader.DataReader, error)
NewInstance returns a mocked version of the config
type Constructor ¶ added in v0.7.0
type Constructor interface { reader.Constructor TestServer() *httptest.Server Object() (reader.DataReader, error) }
Constructor is an interface for setting up an object for testing. TestServer() should return a ready to use test server Object() should return the instantiated object
type Reader ¶ added in v0.7.0
type Reader struct { ReadFunc func(*token.Context) (*reader.Result, error) Pinged bool // contains filtered or unexported fields }
Reader is useful for testing purposes.
func New ¶ added in v0.7.0
func New(options ...func(reader.Constructor) error) (*Reader, error)
New is a reader for using in tests
func (*Reader) Logger ¶ added in v0.8.1
func (r *Reader) Logger() internal.FieldLogger
Logger returns the log
func (*Reader) Read ¶ added in v0.7.0
Read executes the ReadFunc if defined, otherwise continues normally
func (*Reader) SetBackoff ¶ added in v0.8.1
SetBackoff sets the backoff of the reader
func (*Reader) SetEndpoint ¶ added in v0.8.1
SetEndpoint sets the endpoint of the reader
func (*Reader) SetInterval ¶ added in v0.8.1
SetInterval sets the interval of the reader
func (*Reader) SetLogger ¶ added in v0.8.1
func (r *Reader) SetLogger(log internal.FieldLogger)
SetLogger sets the log of the reader
func (*Reader) SetTimeout ¶ added in v0.8.1
SetTimeout sets the timeout of the reader
func (*Reader) SetTypeName ¶ added in v0.8.1
SetTypeName sets the type name of the reader