reltest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConnectionClosed is alias for sql.ErrConnDone.
	ErrConnectionClosed = sql.ErrConnDone
)

Functions

This section is empty.

Types

type Aggregate

type Aggregate struct {
	*Expect
}

Aggregate asserts and simulate aggregate function for test.

func ExpectAggregate

func ExpectAggregate(r *Repository, query rel.Query, aggregate string, field string) *Aggregate

ExpectAggregate to be called with given field and queries.

func ExpectCount

func ExpectCount(r *Repository, collection string, queriers []rel.Querier) *Aggregate

ExpectCount to be called with given field and queries.

func (*Aggregate) ConnectionClosed

func (a *Aggregate) ConnectionClosed()

ConnectionClosed sets this error to be returned.

func (*Aggregate) Error

func (a *Aggregate) Error(err error)

Error sets error to be returned.

func (*Aggregate) Result

func (a *Aggregate) Result(count int)

Result sets the result of this query.

type Delete

type Delete struct {
	*Expect
}

Delete asserts and simulate delete function for test.

func ExpectDelete

func ExpectDelete(r *Repository, options []rel.Cascade) *Delete

ExpectDelete to be called.

func (*Delete) For

func (d *Delete) For(record interface{}) *Delete

For match expect calls for given record.

func (*Delete) ForType

func (d *Delete) ForType(typ string) *Delete

ForType match expect calls for given type. Type must include package name, example: `model.User`.

type Expect

type Expect struct {
	*mock.Call
}

Expect is base behaviour for all reltest expectations.

func (*Expect) ConnectionClosed

func (e *Expect) ConnectionClosed()

ConnectionClosed sets this error to be returned.

func (*Expect) Error

func (e *Expect) Error(err error)

Error sets error to be returned.

type Find

type Find struct {
	*FindAll
}

Find asserts and simulate find function for test.

func ExpectFind

func ExpectFind(r *Repository, queriers []rel.Querier) *Find

ExpectFind to be called with given field and queries.

func (*Find) NotFound added in v0.2.0

func (f *Find) NotFound()

NotFound sets NotFoundError to be returned.

type FindAll

type FindAll struct {
	*Expect
}

FindAll asserts and simulate find all function for test.

func ExpectFindAll

func ExpectFindAll(r *Repository, queriers []rel.Querier) *FindAll

ExpectFindAll to be called with given field and queries.

func (*FindAll) Result

func (fa *FindAll) Result(records interface{})

Result sets the result of this query.

type FindAndCountAll added in v0.3.0

type FindAndCountAll struct {
	*Expect
}

FindAndCountAll asserts and simulate find all function for test.

func ExpectFindAndCountAll added in v0.3.0

func ExpectFindAndCountAll(r *Repository, queriers []rel.Querier) *FindAndCountAll

ExpectFindAndCountAll to be called with given field and queries.

func (*FindAndCountAll) ConnectionClosed added in v0.3.0

func (fa *FindAndCountAll) ConnectionClosed()

ConnectionClosed sets this error to be returned.

func (*FindAndCountAll) Error added in v0.3.0

func (fa *FindAndCountAll) Error(err error)

Error sets error to be returned.

func (*FindAndCountAll) Result added in v0.3.0

func (fa *FindAndCountAll) Result(records interface{}, count int)

Result sets the result of this query.

type Iterate added in v0.3.0

type Iterate iterator

Iterate asserts and simulate iterate function for test.

func ExpectIterate added in v0.3.0

func ExpectIterate(r *Repository, query rel.Query, options []rel.IteratorOption) *Iterate

ExpectIterate to be called.

func (*Iterate) ConnectionClosed added in v0.3.0

func (i *Iterate) ConnectionClosed()

ConnectionClosed sets this error to be returned.

func (*Iterate) Error added in v0.3.0

func (i *Iterate) Error(err error)

Error sets error to be returned.

func (*Iterate) Result added in v0.3.0

func (i *Iterate) Result(records interface{})

Result sets the result of this query.

type Mutate added in v0.4.0

type Mutate struct {
	*Expect
}

Mutate asserts and simulate insert or update function for test.

func ExpectInsert added in v0.3.0

func ExpectInsert(r *Repository, mutators []rel.Mutator) *Mutate

ExpectInsert to be called with given field and queries.

func ExpectInsertAll

func ExpectInsertAll(r *Repository) *Mutate

ExpectInsertAll to be called.

func ExpectUpdate added in v0.3.0

func ExpectUpdate(r *Repository, mutators []rel.Mutator) *Mutate

ExpectUpdate to be called with given field and queries.

func (*Mutate) For added in v0.4.0

func (m *Mutate) For(record interface{}) *Mutate

For match expect calls for given record.

func (*Mutate) ForType added in v0.4.0

func (m *Mutate) ForType(typ string) *Mutate

ForType match expect calls for given type. Type must include package name, example: `model.User`.

func (*Mutate) NotUnique added in v0.4.0

func (m *Mutate) NotUnique(key string)

NotUnique sets not unique error to be returned.

type MutateAll added in v0.5.0

type MutateAll struct {
	*Expect
}

MutateAll asserts and simulate mutate all function for test.

func ExpectDeleteAll

func ExpectDeleteAll(r *Repository, query rel.Query) *MutateAll

ExpectDeleteAll to be called.

func ExpectUpdateAll added in v0.5.0

func ExpectUpdateAll(r *Repository, query rel.Query, mutates []rel.Mutate) *MutateAll

ExpectUpdateAll to be called.

func (*MutateAll) Unsafe added in v0.5.0

func (ema *MutateAll) Unsafe()

Unsafe allows for unsafe operation that doesn't contains where clause.

type Preload

type Preload struct {
	*Expect
}

Preload asserts and simulate preload function for test.

func ExpectPreload

func ExpectPreload(r *Repository, field string, queriers []rel.Querier) *Preload

ExpectPreload to be called with given field and queries.

func (*Preload) For

func (p *Preload) For(record interface{}) *Preload

For match expect calls for given record.

func (*Preload) ForType

func (p *Preload) ForType(typ string) *Preload

ForType match expect calls for given type. Type must include package name, example: `model.User`.

func (*Preload) Result

func (p *Preload) Result(records interface{})

Result sets the result of Preload query.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository is an autogenerated mock type for the Repository type

func New added in v0.1.1

func New() *Repository

New test repository.

func (*Repository) Adapter

func (r *Repository) Adapter(ctx context.Context) rel.Adapter

Adapter provides a mock function with given fields:

func (*Repository) Aggregate

func (r *Repository) Aggregate(ctx context.Context, query rel.Query, aggregate string, field string) (int, error)

Aggregate provides a mock function with given fields: query, aggregate, field

func (*Repository) AssertExpectations

func (r *Repository) AssertExpectations(t *testing.T) bool

AssertExpectations asserts that everything was in fact called as expected. Calls may have occurred in any order.

func (*Repository) Count

func (r *Repository) Count(ctx context.Context, collection string, queriers ...rel.Querier) (int, error)

Count provides a mock function with given fields: collection, queriers

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, record interface{}, options ...rel.Cascade) error

Delete provides a mock function with given fields: record

func (*Repository) DeleteAll

func (r *Repository) DeleteAll(ctx context.Context, query rel.Query) error

DeleteAll provides a mock function with given fields: query

func (*Repository) ExpectAggregate

func (r *Repository) ExpectAggregate(query rel.Query, aggregate string, field string) *Aggregate

ExpectAggregate apply mocks and expectations for Aggregate

func (*Repository) ExpectCount

func (r *Repository) ExpectCount(collection string, queriers ...rel.Querier) *Aggregate

ExpectCount apply mocks and expectations for Count

func (*Repository) ExpectDelete

func (r *Repository) ExpectDelete(options ...rel.Cascade) *Delete

ExpectDelete apply mocks and expectations for Delete

func (*Repository) ExpectDeleteAll

func (r *Repository) ExpectDeleteAll(query rel.Query) *MutateAll

ExpectDeleteAll apply mocks and expectations for DeleteAll

func (*Repository) ExpectFind

func (r *Repository) ExpectFind(queriers ...rel.Querier) *Find

ExpectFind apply mocks and expectations for Find

func (*Repository) ExpectFindAll

func (r *Repository) ExpectFindAll(queriers ...rel.Querier) *FindAll

ExpectFindAll apply mocks and expectations for FindAll

func (*Repository) ExpectFindAndCountAll added in v0.3.0

func (r *Repository) ExpectFindAndCountAll(queriers ...rel.Querier) *FindAndCountAll

ExpectFindAndCountAll apply mocks and expectations for FindAndCountAll

func (*Repository) ExpectInsert

func (r *Repository) ExpectInsert(mutators ...rel.Mutator) *Mutate

ExpectInsert apply mocks and expectations for Insert

func (*Repository) ExpectInsertAll

func (r *Repository) ExpectInsertAll() *Mutate

ExpectInsertAll records.

func (*Repository) ExpectIterate added in v0.3.0

func (r *Repository) ExpectIterate(query rel.Query, options ...rel.IteratorOption) *Iterate

ExpectIterate apply mocks and expectations for Iterate

func (*Repository) ExpectPreload

func (r *Repository) ExpectPreload(field string, queriers ...rel.Querier) *Preload

ExpectPreload apply mocks and expectations for Preload

func (*Repository) ExpectTransaction

func (r *Repository) ExpectTransaction(fn func(*Repository))

ExpectTransaction declare expectation inside transaction.

func (*Repository) ExpectUpdate

func (r *Repository) ExpectUpdate(mutators ...rel.Mutator) *Mutate

ExpectUpdate apply mocks and expectations for Update

func (*Repository) ExpectUpdateAll added in v0.5.0

func (r *Repository) ExpectUpdateAll(query rel.Query, mutates ...rel.Mutate) *MutateAll

ExpectUpdateAll apply mocks and expectations for UpdateAll

func (*Repository) Find

func (r *Repository) Find(ctx context.Context, record interface{}, queriers ...rel.Querier) error

Find provides a mock function with given fields: record, queriers

func (*Repository) FindAll

func (r *Repository) FindAll(ctx context.Context, records interface{}, queriers ...rel.Querier) error

FindAll provides a mock function with given fields: records, queriers

func (*Repository) FindAndCountAll added in v0.3.0

func (r *Repository) FindAndCountAll(ctx context.Context, records interface{}, queriers ...rel.Querier) (int, error)

FindAndCountAll provides a mock function with given fields: records, queriers

func (*Repository) Insert

func (r *Repository) Insert(ctx context.Context, record interface{}, mutators ...rel.Mutator) error

Insert provides a mock function with given fields: record, mutators

func (*Repository) InsertAll

func (r *Repository) InsertAll(ctx context.Context, records interface{}) error

InsertAll records.

func (*Repository) Instrumentation added in v0.3.0

func (r *Repository) Instrumentation(instrumenter rel.Instrumenter)

Instrumentation provides a mock function with given fields: instrumenter

func (*Repository) Iterate added in v0.3.0

func (r *Repository) Iterate(ctx context.Context, query rel.Query, options ...rel.IteratorOption) rel.Iterator

Iterate through a collection of records from database in batches. This function returns iterator that can be used to loop all records. Limit, Offset and Sort query is automatically ignored.

func (*Repository) MustAggregate

func (r *Repository) MustAggregate(ctx context.Context, query rel.Query, aggregate string, field string) int

MustAggregate provides a mock function with given fields: query, aggregate, field

func (*Repository) MustCount

func (r *Repository) MustCount(ctx context.Context, collection string, queriers ...rel.Querier) int

MustCount provides a mock function with given fields: collection, queriers

func (*Repository) MustDelete

func (r *Repository) MustDelete(ctx context.Context, record interface{}, options ...rel.Cascade)

MustDelete provides a mock function with given fields: record

func (*Repository) MustDeleteAll

func (r *Repository) MustDeleteAll(ctx context.Context, query rel.Query)

MustDeleteAll provides a mock function with given fields: query

func (*Repository) MustFind

func (r *Repository) MustFind(ctx context.Context, record interface{}, queriers ...rel.Querier)

MustFind provides a mock function with given fields: record, queriers

func (*Repository) MustFindAll

func (r *Repository) MustFindAll(ctx context.Context, records interface{}, queriers ...rel.Querier)

MustFindAll provides a mock function with given fields: records, queriers

func (*Repository) MustFindAndCountAll added in v0.3.0

func (r *Repository) MustFindAndCountAll(ctx context.Context, records interface{}, queriers ...rel.Querier) int

MustFindAndCountAll provides a mock function with given fields: records, queriers

func (*Repository) MustInsert

func (r *Repository) MustInsert(ctx context.Context, record interface{}, mutators ...rel.Mutator)

MustInsert provides a mock function with given fields: record, mutators

func (*Repository) MustInsertAll

func (r *Repository) MustInsertAll(ctx context.Context, records interface{})

MustInsertAll records.

func (*Repository) MustPreload

func (r *Repository) MustPreload(ctx context.Context, records interface{}, field string, queriers ...rel.Querier)

MustPreload provides a mock function with given fields: records, field, queriers

func (*Repository) MustUpdate

func (r *Repository) MustUpdate(ctx context.Context, record interface{}, mutators ...rel.Mutator)

MustUpdate provides a mock function with given fields: record, mutators

func (*Repository) MustUpdateAll added in v0.5.0

func (r *Repository) MustUpdateAll(ctx context.Context, query rel.Query, mutates ...rel.Mutate)

MustUpdateAll provides a mock function with given fields: query

func (*Repository) Ping added in v0.2.0

func (r *Repository) Ping(ctx context.Context) error

Ping database.

func (*Repository) Preload

func (r *Repository) Preload(ctx context.Context, records interface{}, field string, queriers ...rel.Querier) error

Preload provides a mock function with given fields: records, field, queriers

func (*Repository) Transaction

func (r *Repository) Transaction(ctx context.Context, fn func(ctx context.Context) error) error

Transaction provides a mock function with given fields: fn

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, record interface{}, mutators ...rel.Mutator) error

Update provides a mock function with given fields: record, mutators

func (*Repository) UpdateAll added in v0.5.0

func (r *Repository) UpdateAll(ctx context.Context, query rel.Query, mutates ...rel.Mutate) error

UpdateAll provides a mock function with given fields: query

Jump to

Keyboard shortcuts

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