example_auxiliary

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCode_ConnectionFailed           = "connection_failed"
	ErrCode_TaskAlreadyExistButNotDone = "already_exist_but_not_done"
	ErrCode_TaskAlreadyExistAndDone    = "already_exist_and_done"
)

Error code to distinguish errors.

Variables

This section is empty.

Functions

func CreateTaskInitedByUser1

func CreateTaskInitedByUser1(i int) error

Pretends to be service logic function that invokes repository db function SaveTaskToDb...().

0 - calls SaveTaskToDbMockConnectionError 1 - calls SaveTaskToDbMockExistButNotDone 2 - calls SaveTaskToDbMockExistAndDone 3 - calls SaveTaskToDbMockSuccess

All errors occured it annotates with information that this task id inited by user 1 using:

errors.WrapAnnotated(SaveTaskToDb...(), "Inited by user 1")

func SaveTaskToDbMockConnectionError

func SaveTaskToDbMockConnectionError() error

It mocks case when one tries to save task to db, but connection error occurs.

It returns error with error code ErrCode_ConnectionFailed using:

errors.New("connection failed", ErrCode_ConnectionFailed)

func SaveTaskToDbMockExistAndDone

func SaveTaskToDbMockExistAndDone() error

It mocks case when one tries to save task to db, but it already exists. Then it asks if task is already done and it occurs it is done.

It returns error with error code ErrCode_TaskAlreadyExistAndDone using:

return errors.New("already exist and done", ErrCode_TaskAlreadyExistAndDone)

func SaveTaskToDbMockExistButNotDone

func SaveTaskToDbMockExistButNotDone() error

It mocks case when one tries to save task to db, but it already exists. Then it asks if task is already done and it occurs it is not.

It returns error with error code ErrCode_TaskAlreadyExistButNotDone using:

return errors.New("already exist", ErrCode_TaskAlreadyExistButNotDone)

func SaveTaskToDbMockSuccess

func SaveTaskToDbMockSuccess() error

It mocks case of successful saving task.

Types

This section is empty.

Jump to

Keyboard shortcuts

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