Documentation
¶
Overview ¶
picard_test provides a mock orm for unit testing
Index ¶
- type MockORM
- func (morm *MockORM) Commit() error
- func (morm *MockORM) CreateModel(model any) error
- func (morm *MockORM) DeleteModel(data any) (int64, error)
- func (morm *MockORM) Deploy(data any) error
- func (morm *MockORM) DeployMultiple(data []any) error
- func (morm *MockORM) FilterModel(request picard.FilterRequest) ([]any, error)
- func (morm *MockORM) Rollback() error
- func (morm *MockORM) SaveModel(model any) error
- func (morm *MockORM) StartTransaction() (*sql.Tx, error)
- type MultiMockORM
- func (multi *MultiMockORM) Commit() error
- func (multi *MultiMockORM) CreateModel(model any) error
- func (multi *MultiMockORM) DeleteModel(data any) (int64, error)
- func (multi *MultiMockORM) Deploy(data any) error
- func (multi *MultiMockORM) DeployMultiple(data []any) error
- func (multi *MultiMockORM) FilterModel(request picard.FilterRequest) ([]any, error)
- func (multi *MultiMockORM) Rollback() error
- func (multi *MultiMockORM) SaveModel(model any) 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 []any
FilterModelError error
FilterModelCalledWith picard.FilterRequest
SaveModelError error
SaveModelCalledWith any
CreateModelError error
CreateModelCalledWith any
DeployError error
DeployCalledWith any
DeployMultipleError error
DeployMultipleCalledWith []any
DeleteModelRowsAffected int64
DeleteModelError error
DeleteModelCalledWith any
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) ([]any, 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 any) error
CreateModel returns the error stored in MockORM, and records the call value
func (*MultiMockORM) DeleteModel ¶
func (multi *MultiMockORM) DeleteModel(data any) (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 any) error
Deploy returns the error stored in MockORM, and records the call value
func (*MultiMockORM) DeployMultiple ¶
func (multi *MultiMockORM) DeployMultiple(data []any) error
DeployMultiple returns the error stored in MockORM, and records the call value
func (*MultiMockORM) FilterModel ¶
func (multi *MultiMockORM) FilterModel(request picard.FilterRequest) ([]any, 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 any) 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