mockgopg

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter struct {
}

Formatter implements orm.Formatter

func (*Formatter) FormatQuery

func (f *Formatter) FormatQuery(b []byte, query string, params ...interface{}) []byte

FormatQuery formats our query and params to byte

type OrmResult

type OrmResult struct {
	// contains filtered or unexported fields
}

OrmResult struct to implements orm.Result

func NewResult

func NewResult(rowAffected, rowReturned int, model interface{}) *OrmResult

NewResult implements orm.Result in go-pg package

func (*OrmResult) Model

func (o *OrmResult) Model() orm.Model

Model implements an orm.Model

func (*OrmResult) RowsAffected

func (o *OrmResult) RowsAffected() int

RowsAffected returns the number of rows affected in the data table

func (*OrmResult) RowsReturned

func (o *OrmResult) RowsReturned() int

RowsReturned returns the number of rows

type SQLMock

type SQLMock struct {
	// contains filtered or unexported fields
}

SQLMock handles query mocks

func NewGoPGDBTest

func NewGoPGDBTest() (conn orm.DB, mock *SQLMock, err error)

NewGoPGDBTest returns method that already implements orm.DB and mock instance to mocking arguments and results.

func (*SQLMock) ExpectExec

func (sqlMock *SQLMock) ExpectExec(query string) *SQLMock

ExpectExec is a builder method that accepts a query in string and returns an SQLMock pointer

func (*SQLMock) ExpectInsert

func (sqlMock *SQLMock) ExpectInsert(models ...interface{}) *SQLMock

ExpectInsert is a builder method that accepts a model as interface and returns an SQLMock pointer

func (*SQLMock) ExpectQuery

func (sqlMock *SQLMock) ExpectQuery(query string) *SQLMock

ExpectQuery accepts a query in string and returns an SQLMock pointer

func (*SQLMock) ExpectQueryOne

func (sqlMock *SQLMock) ExpectQueryOne(query string) *SQLMock

ExpectQueryOne accepts a query in string and returns an SQLMock pointer

func (*SQLMock) FlushAll

func (sqlMock *SQLMock) FlushAll()

FlushAll resets our sqlMock object

func (*SQLMock) Returns

func (sqlMock *SQLMock) Returns(result *OrmResult, err error)

Returns accepts expected result and error, and completes the build of our sqlMock object

func (*SQLMock) WithArgs

func (sqlMock *SQLMock) WithArgs(params ...interface{}) *SQLMock

WithArgs is a builder method that accepts a query in string and returns an SQLMock pointer

Jump to

Keyboard shortcuts

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