mock

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is used for Get and GetList when no entity is found
	ErrNotFound = errors.New("entity not found")
	// ErrBadRequest is used when the request is malformed or wrong
	ErrBadRequest = errors.New("bad request")
	// ErrForbidden is used when the request is malformed or wrong
	ErrForbidden = errors.New("forbidden")
)

Functions

This section is empty.

Types

type Entity

type Entity struct {
	ID       xid.ID `json:"id"`
	StatusID int    `json:"status_id"`
}

Entity is respecting the CRUD interface

type Mgr

type Mgr struct {
	WantCreateError        bool
	WantDeleteError        bool
	WantGetError           bool
	WantGetListError       bool
	WantUpdateError        bool
	WantPartialUpdateError bool
	EntityList             map[xid.ID]*Entity
}

Mgr is a mock for the mgr interface

func NewMgr

func NewMgr() *Mgr

func (*Mgr) Create

func (m *Mgr) Create(
	ctx context.Context,
	e interface{},
	pl io.Reader,
) (interface{}, error)

func (*Mgr) Delete

func (m *Mgr) Delete(ctx context.Context, id xid.ID) error

func (*Mgr) Get

func (m *Mgr) Get(ctx context.Context, id xid.ID) (interface{}, error)

func (*Mgr) GetList

func (m *Mgr) GetList(
	context.Context,
	crud.ListModifiers,
) (interface{}, error)

func (*Mgr) MapErrorToHTTPError

func (m *Mgr) MapErrorToHTTPError(e error) *gohttperror.ErrResponse

func (*Mgr) NewEmptyEntity

func (m *Mgr) NewEmptyEntity() interface{}

func (*Mgr) PartialUpdate

func (m *Mgr) PartialUpdate(
	ctx context.Context,
	id xid.ID,
	pud crud.PartialUpdateData,
	pl io.Reader,
) error

func (*Mgr) Update

func (m *Mgr) Update(
	ctx context.Context,
	id xid.ID,
	newE interface{},
	pl io.Reader,
) (interface{}, error)

Jump to

Keyboard shortcuts

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