reltest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: MIT Imports: 8 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) *Delete

ExpectDelete to be called with given field and queries.

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 DeleteAll

type DeleteAll struct {
	*Expect
}

DeleteAll asserts and simulate delete all function for test.

func ExpectDeleteAll

func ExpectDeleteAll(r *Repository, queriers []rel.Querier) *DeleteAll

ExpectDeleteAll to be called with given field and queries.

func (*DeleteAll) Unsafe

func (eda *DeleteAll) Unsafe()

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

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) NoResult

func (f *Find) NoResult()

NoResult sets NoResultError 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 Modify

type Modify struct {
	*Expect
}

Modify asserts and simulate insert or update function for test.

func ExpectInsertAll

func ExpectInsertAll(r *Repository, changes []rel.Changes) *Modify

ExpectInsertAll to be called with given field and queries.

func ExpectModify

func ExpectModify(r *Repository, methodName string, changers []rel.Changer, insertion bool) *Modify

ExpectModify to be called with given field and queries.

func (*Modify) For

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

For match expect calls for given record.

func (*Modify) ForType

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

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

func (*Modify) NotUnique

func (m *Modify) NotUnique(key string)

NotUnique sets not unique error to be returned.

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 (*Repository) Adapter

func (r *Repository) Adapter() rel.Adapter

Adapter provides a mock function with given fields:

func (*Repository) Aggregate

func (r *Repository) Aggregate(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(collection string, queriers ...rel.Querier) (int, error)

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

func (*Repository) Delete

func (r *Repository) Delete(record interface{}) error

Delete provides a mock function with given fields: record

func (*Repository) DeleteAll

func (r *Repository) DeleteAll(queriers ...rel.Querier) error

DeleteAll provides a mock function with given fields: queriers

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() *Delete

ExpectDelete apply mocks and expectations for Delete

func (*Repository) ExpectDeleteAll

func (r *Repository) ExpectDeleteAll(queriers ...rel.Querier) *DeleteAll

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) ExpectInsert

func (r *Repository) ExpectInsert(changers ...rel.Changer) *Modify

ExpectInsert apply mocks and expectations for Insert

func (*Repository) ExpectInsertAll

func (r *Repository) ExpectInsertAll(changes ...rel.Changes) *Modify

ExpectInsertAll apply mocks and expectations for InsertAll

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(changers ...rel.Changer) *Modify

ExpectUpdate apply mocks and expectations for Update

func (*Repository) Find

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

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

func (*Repository) FindAll

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

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

func (*Repository) Insert

func (r *Repository) Insert(record interface{}, changers ...rel.Changer) error

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

func (*Repository) InsertAll

func (r *Repository) InsertAll(records interface{}, changes ...rel.Changes) error

InsertAll provides a mock function with given fields: records, changes

func (*Repository) MustAggregate

func (r *Repository) MustAggregate(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(collection string, queriers ...rel.Querier) int

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

func (*Repository) MustDelete

func (r *Repository) MustDelete(record interface{})

MustDelete provides a mock function with given fields: record

func (*Repository) MustDeleteAll

func (r *Repository) MustDeleteAll(queriers ...rel.Querier)

MustDeleteAll provides a mock function with given fields: queriers

func (*Repository) MustFind

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

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

func (*Repository) MustFindAll

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

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

func (*Repository) MustInsert

func (r *Repository) MustInsert(record interface{}, changers ...rel.Changer)

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

func (*Repository) MustInsertAll

func (r *Repository) MustInsertAll(records interface{}, changes ...rel.Changes)

MustInsertAll provides a mock function with given fields: records, changes

func (*Repository) MustPreload

func (r *Repository) MustPreload(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(record interface{}, changers ...rel.Changer)

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

func (*Repository) Preload

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

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

func (*Repository) SetLogger

func (r *Repository) SetLogger(logger ...rel.Logger)

SetLogger provides a mock function with given fields: logger

func (*Repository) Transaction

func (r *Repository) Transaction(fn func(rel.Repository) error) error

Transaction provides a mock function with given fields: fn

func (*Repository) Update

func (r *Repository) Update(record interface{}, changers ...rel.Changer) error

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

Jump to

Keyboard shortcuts

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