mockrepo

package
v0.21.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonExecuter

type CommonExecuter struct {
	Options     *Options
	ExecuteFunc CommonFunc
}

CommonExecuter is an executor of the common function.

type CommonFunc

type CommonFunc func(ctx context.Context, s *query.Scope) error

CommonFunc is a common repository function.

type Option

type Option func(o *Options)

Option is function that changes options.

func Count

func Count(count int) Option

Count sets the number of executions of given function.

func Permanent

func Permanent() Option

Permanent is a permanent option

type Options

type Options struct {
	Permanent bool
	Count     int
}

Options are the settings for the OnXXX functions.

type Repository

type Repository struct {
	IDValue                string
	Beginners              []*TransExecuter
	Committers             []*TransExecuter
	Rollbackers            []*TransExecuter
	Savepointers           []*SavepointExecuter
	RollbackerSavepointers []*SavepointExecuter
	Inserters              []*CommonExecuter
	Finders                []*CommonExecuter
	Counters               []*ResultExecuter
	Updaters               []*ResultExecuter
	ModelUpdaters          []*ResultExecuter
	Deleters               []*ResultExecuter
}

Repository is a mock repository implementation.

func (*Repository) Begin

func (r *Repository) Begin(ctx context.Context, tx *query.Transaction) error

Begin implements repository.Transactioner interface.

func (*Repository) Commit

func (r *Repository) Commit(ctx context.Context, tx *query.Transaction) error

Commit implements repository.Transactioner.

func (*Repository) Count

func (r *Repository) Count(ctx context.Context, s *query.Scope) (int64, error)

Count implements repository.Repository interface.

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, s *query.Scope) (int64, error)

Delete implements repository.Repository.

func (*Repository) Find

func (r *Repository) Find(ctx context.Context, s *query.Scope) error

Find implements repository.Repository interface.

func (*Repository) ID

func (r *Repository) ID() string

ID implements repository.Repository.

func (*Repository) Insert

func (r *Repository) Insert(ctx context.Context, s *query.Scope) error

Insert implements repository.Repository interface.

func (*Repository) OnBegin

func (r *Repository) OnBegin(transFunc TransFunc, options ...Option)

OnBegin adds begin executor.

func (*Repository) OnCommit

func (r *Repository) OnCommit(transFunc TransFunc, options ...Option)

OnCommit adds the committer executer.

func (*Repository) OnCount

func (r *Repository) OnCount(resultFunc ResultFunc, options ...Option)

OnCount adds the count function executioner.

func (*Repository) OnDelete

func (r *Repository) OnDelete(deleteFunc ResultFunc, options ...Option)

OnDelete adds the delete function executioner.

func (*Repository) OnFind

func (r *Repository) OnFind(findFunc CommonFunc, options ...Option)

OnFind adds the find executioner function.

func (*Repository) OnInsert

func (r *Repository) OnInsert(insertFunc CommonFunc, options ...Option)

OnInsert adds the insert executioner function.

func (*Repository) OnRollback

func (r *Repository) OnRollback(transFunc TransFunc, options ...Option)

OnRollback adds the committer executer.

func (*Repository) OnRollbackSavepoint added in v0.20.0

func (r *Repository) OnRollbackSavepoint(savepointFunc SavepointFunc, options ...Option)

OnRollbackSavepoint adds the delete function executioner.

func (*Repository) OnSavepoint added in v0.20.0

func (r *Repository) OnSavepoint(savepointFunc SavepointFunc, options ...Option)

OnSavepoint adds the delete function executioner.

func (*Repository) OnUpdate

func (r *Repository) OnUpdate(updateFunc ResultFunc, options ...Option)

OnUpdate adds the count function executioner.

func (*Repository) OnUpdateModels

func (r *Repository) OnUpdateModels(updateFunc ResultFunc, options ...Option)

OnUpdateModels adds the count function executioner.

func (*Repository) Rollback

func (r *Repository) Rollback(ctx context.Context, tx *query.Transaction) error

Rollback implements repository.Transactioner.

func (*Repository) RollbackSavepoint added in v0.20.0

func (r *Repository) RollbackSavepoint(ctx context.Context, tx *query.Transaction, name string) error

RollbackSavepoint implements repository.Savepointer.

func (*Repository) Savepoint added in v0.20.0

func (r *Repository) Savepoint(ctx context.Context, tx *query.Transaction, name string) error

Savepoint implements repository.Savepointer

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, s *query.Scope) (int64, error)

Update implements repository.Repository.

func (*Repository) UpdateModels

func (r *Repository) UpdateModels(ctx context.Context, s *query.Scope) (int64, error)

UpdateModels implements repository.Repository.

type ResultExecuter

type ResultExecuter struct {
	Options     *Options
	ExecuteFunc ResultFunc
}

ResultExecuter is an executor of the result function.

type ResultFunc

type ResultFunc func(ctx context.Context, s *query.Scope) (int64, error)

ResultFunc is a repository function that returns int64 and error.

type SavepointExecuter added in v0.20.0

type SavepointExecuter struct {
	Options     *Options
	ExecuteFunc SavepointFunc
}

SavepointExecuter is an executor of the transaction functions.

type SavepointFunc added in v0.20.0

type SavepointFunc func(context.Context, *query.Transaction, string) error

SavepointFunc is trans execution function.

type TransExecuter

type TransExecuter struct {
	Options     *Options
	ExecuteFunc TransFunc
}

TransExecuter is an executor of the transaction functions.

type TransFunc

type TransFunc func(context.Context, *query.Transaction) error

TransFunc is trans execution function.

Jump to

Keyboard shortcuts

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