Documentation
¶
Overview ¶
picard_test provides a mock orm for unit testing
Index ¶
- type MockORM
- func (morm *MockORM) Commit() error
- func (morm *MockORM) CreateModel(model interface{}) error
- func (morm *MockORM) DeleteModel(data interface{}) (int64, error)
- func (morm *MockORM) Deploy(data interface{}) error
- func (morm *MockORM) DeployMultiple(data []interface{}) error
- func (morm *MockORM) FilterModel(request picard.FilterRequest) ([]interface{}, error)
- func (morm *MockORM) Rollback() error
- func (morm *MockORM) SaveModel(model interface{}) error
- func (morm *MockORM) StartTransaction() (*sql.Tx, error)
- type MultiMockORM
- func (multi *MultiMockORM) Commit() error
- func (multi *MultiMockORM) CreateModel(model interface{}) error
- func (multi *MultiMockORM) DeleteModel(data interface{}) (int64, error)
- func (multi *MultiMockORM) Deploy(data interface{}) error
- func (multi *MultiMockORM) DeployMultiple(data []interface{}) error
- func (multi *MultiMockORM) FilterModel(request picard.FilterRequest) ([]interface{}, error)
- func (multi *MultiMockORM) Rollback() error
- func (multi *MultiMockORM) SaveModel(model interface{}) error
- func (multi *MultiMockORM) StartTransaction() (*sql.Tx, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockORM ¶
type MockORM struct { FilterModelReturns []interface{} FilterModelError error FilterModelCalledWith picard.FilterRequest SaveModelError error SaveModelCalledWith interface{} CreateModelError error CreateModelCalledWith interface{} DeployError error DeployCalledWith interface{} DeployMultipleError error DeployMultipleCalledWith []interface{} DeleteModelRowsAffected int64 DeleteModelError error DeleteModelCalledWith interface{} StartTransactionReturns *sql.Tx StartTransactionError error CommitError error RollbackError error }
MockORM can be used to test client functionality that calls picard.ORM behavior.
func (*MockORM) CreateModel ¶
CreateModel returns the error stored in MockORM, and records the call value
func (*MockORM) DeleteModel ¶
DeleteModel returns the rows affected number & error stored in MockORM, and records the call value
func (*MockORM) DeployMultiple ¶
DeployMultiple returns the error stored in MockORM, and records the call value
func (*MockORM) FilterModel ¶
func (morm *MockORM) FilterModel(request picard.FilterRequest) ([]interface{}, error)
FilterModel simply returns an error or return objects when set on the MockORM
type MultiMockORM ¶
type MultiMockORM struct { MockORMs []MockORM // If initialized, you can use TypeMap instead of the MockORMs array to return specific types of results for specific // requests (for example, when using goroutines to do parallel fetching of many models at once). TypeMap map[string]MockORM // contains filtered or unexported fields }
MultiMockORM can be used to string together a series of calls to picard.ORM
func (*MultiMockORM) Commit ¶
func (multi *MultiMockORM) Commit() error
Commit returns the error stored in MockORM
func (*MultiMockORM) CreateModel ¶
func (multi *MultiMockORM) CreateModel(model interface{}) error
CreateModel returns the error stored in MockORM, and records the call value
func (*MultiMockORM) DeleteModel ¶
func (multi *MultiMockORM) DeleteModel(data interface{}) (int64, error)
DeleteModel returns the rows affected number & error stored in MockORM, and records the call value
func (*MultiMockORM) Deploy ¶
func (multi *MultiMockORM) Deploy(data interface{}) error
Deploy returns the error stored in MockORM, and records the call value
func (*MultiMockORM) DeployMultiple ¶
func (multi *MultiMockORM) DeployMultiple(data []interface{}) error
DeployMultiple returns the error stored in MockORM, and records the call value
func (*MultiMockORM) FilterModel ¶
func (multi *MultiMockORM) FilterModel(request picard.FilterRequest) ([]interface{}, error)
FilterModel simply returns an error or return objects when set on the MockORM
func (*MultiMockORM) Rollback ¶
func (multi *MultiMockORM) Rollback() error
Commit returns the error stored in MockORM
func (*MultiMockORM) SaveModel ¶
func (multi *MultiMockORM) SaveModel(model interface{}) error
SaveModel returns the error stored in MockORM, and records the call value
func (*MultiMockORM) StartTransaction ¶
func (multi *MultiMockORM) StartTransaction() (*sql.Tx, error)
StartTransaction returns the error stored in MockORM and returns the value stored in the orm