picard_test

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

picard_test provides a mock orm for unit testing

Index

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) Commit

func (morm *MockORM) Commit() error

Commit returns the error stored in MockORM

func (*MockORM) CreateModel

func (morm *MockORM) CreateModel(model interface{}) error

CreateModel returns the error stored in MockORM, and records the call value

func (*MockORM) DeleteModel

func (morm *MockORM) DeleteModel(data interface{}) (int64, error)

DeleteModel returns the rows affected number & error stored in MockORM, and records the call value

func (*MockORM) Deploy

func (morm *MockORM) Deploy(data interface{}) error

Deploy returns the error stored in MockORM, and records the call value

func (*MockORM) DeployMultiple

func (morm *MockORM) DeployMultiple(data []interface{}) error

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

func (*MockORM) Rollback

func (morm *MockORM) Rollback() error

Rollback returns the error stored in MockORM

func (*MockORM) SaveModel

func (morm *MockORM) SaveModel(model interface{}) error

SaveModel returns the error stored in MockORM, and records the call value

func (*MockORM) StartTransaction

func (morm *MockORM) StartTransaction() (*sql.Tx, error)

StartTransaction returns the error stored in MockORM and returns the value stored in the orm

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

Jump to

Keyboard shortcuts

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