mock

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PGXPoolMock

type PGXPoolMock struct {
	// BeginFunc mocks the Begin method.
	BeginFunc func(ctx context.Context) (v4.Tx, error)

	// CloseFunc mocks the Close method.
	CloseFunc func()

	// ExecFunc mocks the Exec method.
	ExecFunc func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

	// PingFunc mocks the Ping method.
	PingFunc func(ctx context.Context) error

	// QueryFunc mocks the Query method.
	QueryFunc func(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)

	// QueryRowFunc mocks the QueryRow method.
	QueryRowFunc func(ctx context.Context, sql string, args ...interface{}) v4.Row
	// contains filtered or unexported fields
}

PGXPoolMock is a mock implementation of pgx.PGXPool.

func TestSomethingThatUsesPGXPool(t *testing.T) {

	// make and configure a mocked pgx.PGXPool
	mockedPGXPool := &PGXPoolMock{
		BeginFunc: func(ctx context.Context) (v4.Tx, error) {
			panic("mock out the Begin method")
		},
		CloseFunc: func()  {
			panic("mock out the Close method")
		},
		ExecFunc: func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) {
			panic("mock out the Exec method")
		},
		PingFunc: func(ctx context.Context) error {
			panic("mock out the Ping method")
		},
		QueryFunc: func(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error) {
			panic("mock out the Query method")
		},
		QueryRowFunc: func(ctx context.Context, sql string, args ...interface{}) v4.Row {
			panic("mock out the QueryRow method")
		},
	}

	// use mockedPGXPool in code that requires pgx.PGXPool
	// and then make assertions.

}

func (*PGXPoolMock) Begin

func (mock *PGXPoolMock) Begin(ctx context.Context) (v4.Tx, error)

Begin calls BeginFunc.

func (*PGXPoolMock) BeginCalls

func (mock *PGXPoolMock) BeginCalls() []struct {
	Ctx context.Context
}

BeginCalls gets all the calls that were made to Begin. Check the length with:

len(mockedPGXPool.BeginCalls())

func (*PGXPoolMock) Close

func (mock *PGXPoolMock) Close()

Close calls CloseFunc.

func (*PGXPoolMock) CloseCalls

func (mock *PGXPoolMock) CloseCalls() []struct {
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedPGXPool.CloseCalls())

func (*PGXPoolMock) Exec added in v0.9.0

func (mock *PGXPoolMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

Exec calls ExecFunc.

func (*PGXPoolMock) ExecCalls added in v0.9.0

func (mock *PGXPoolMock) ExecCalls() []struct {
	Ctx       context.Context
	SQL       string
	Arguments []interface{}
}

ExecCalls gets all the calls that were made to Exec. Check the length with:

len(mockedPGXPool.ExecCalls())

func (*PGXPoolMock) Ping

func (mock *PGXPoolMock) Ping(ctx context.Context) error

Ping calls PingFunc.

func (*PGXPoolMock) PingCalls

func (mock *PGXPoolMock) PingCalls() []struct {
	Ctx context.Context
}

PingCalls gets all the calls that were made to Ping. Check the length with:

len(mockedPGXPool.PingCalls())

func (*PGXPoolMock) Query

func (mock *PGXPoolMock) Query(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)

Query calls QueryFunc.

func (*PGXPoolMock) QueryCalls

func (mock *PGXPoolMock) QueryCalls() []struct {
	Ctx  context.Context
	SQL  string
	Args []interface{}
}

QueryCalls gets all the calls that were made to Query. Check the length with:

len(mockedPGXPool.QueryCalls())

func (*PGXPoolMock) QueryRow

func (mock *PGXPoolMock) QueryRow(ctx context.Context, sql string, args ...interface{}) v4.Row

QueryRow calls QueryRowFunc.

func (*PGXPoolMock) QueryRowCalls

func (mock *PGXPoolMock) QueryRowCalls() []struct {
	Ctx  context.Context
	SQL  string
	Args []interface{}
}

QueryRowCalls gets all the calls that were made to QueryRow. Check the length with:

len(mockedPGXPool.QueryRowCalls())

type PGXRowMock added in v0.10.0

type PGXRowMock struct {
	// ScanFunc mocks the Scan method.
	ScanFunc func(dest ...interface{}) error
	// contains filtered or unexported fields
}

PGXRowMock is a mock implementation of pgx.PGXRow.

func TestSomethingThatUsesPGXRow(t *testing.T) {

	// make and configure a mocked pgx.PGXRow
	mockedPGXRow := &PGXRowMock{
		ScanFunc: func(dest ...interface{}) error {
			panic("mock out the Scan method")
		},
	}

	// use mockedPGXRow in code that requires pgx.PGXRow
	// and then make assertions.

}

func (*PGXRowMock) Scan added in v0.10.0

func (mock *PGXRowMock) Scan(dest ...interface{}) error

Scan calls ScanFunc.

func (*PGXRowMock) ScanCalls added in v0.10.0

func (mock *PGXRowMock) ScanCalls() []struct {
	Dest []interface{}
}

ScanCalls gets all the calls that were made to Scan. Check the length with:

len(mockedPGXRow.ScanCalls())

type PGXRowsMock added in v0.10.0

type PGXRowsMock struct {
	// CloseFunc mocks the Close method.
	CloseFunc func()

	// CommandTagFunc mocks the CommandTag method.
	CommandTagFunc func() pgconn.CommandTag

	// ErrFunc mocks the Err method.
	ErrFunc func() error

	// FieldDescriptionsFunc mocks the FieldDescriptions method.
	FieldDescriptionsFunc func() []pgproto3.FieldDescription

	// NextFunc mocks the Next method.
	NextFunc func() bool

	// RawValuesFunc mocks the RawValues method.
	RawValuesFunc func() [][]byte

	// ScanFunc mocks the Scan method.
	ScanFunc func(dest ...interface{}) error

	// ValuesFunc mocks the Values method.
	ValuesFunc func() ([]interface{}, error)
	// contains filtered or unexported fields
}

PGXRowsMock is a mock implementation of pgx.PGXRows.

func TestSomethingThatUsesPGXRows(t *testing.T) {

	// make and configure a mocked pgx.PGXRows
	mockedPGXRows := &PGXRowsMock{
		CloseFunc: func()  {
			panic("mock out the Close method")
		},
		CommandTagFunc: func() pgconn.CommandTag {
			panic("mock out the CommandTag method")
		},
		ErrFunc: func() error {
			panic("mock out the Err method")
		},
		FieldDescriptionsFunc: func() []pgproto3.FieldDescription {
			panic("mock out the FieldDescriptions method")
		},
		NextFunc: func() bool {
			panic("mock out the Next method")
		},
		RawValuesFunc: func() [][]byte {
			panic("mock out the RawValues method")
		},
		ScanFunc: func(dest ...interface{}) error {
			panic("mock out the Scan method")
		},
		ValuesFunc: func() ([]interface{}, error) {
			panic("mock out the Values method")
		},
	}

	// use mockedPGXRows in code that requires pgx.PGXRows
	// and then make assertions.

}

func (*PGXRowsMock) Close added in v0.10.0

func (mock *PGXRowsMock) Close()

Close calls CloseFunc.

func (*PGXRowsMock) CloseCalls added in v0.10.0

func (mock *PGXRowsMock) CloseCalls() []struct {
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedPGXRows.CloseCalls())

func (*PGXRowsMock) CommandTag added in v0.10.0

func (mock *PGXRowsMock) CommandTag() pgconn.CommandTag

CommandTag calls CommandTagFunc.

func (*PGXRowsMock) CommandTagCalls added in v0.10.0

func (mock *PGXRowsMock) CommandTagCalls() []struct {
}

CommandTagCalls gets all the calls that were made to CommandTag. Check the length with:

len(mockedPGXRows.CommandTagCalls())

func (*PGXRowsMock) Err added in v0.10.0

func (mock *PGXRowsMock) Err() error

Err calls ErrFunc.

func (*PGXRowsMock) ErrCalls added in v0.10.0

func (mock *PGXRowsMock) ErrCalls() []struct {
}

ErrCalls gets all the calls that were made to Err. Check the length with:

len(mockedPGXRows.ErrCalls())

func (*PGXRowsMock) FieldDescriptions added in v0.10.0

func (mock *PGXRowsMock) FieldDescriptions() []pgproto3.FieldDescription

FieldDescriptions calls FieldDescriptionsFunc.

func (*PGXRowsMock) FieldDescriptionsCalls added in v0.10.0

func (mock *PGXRowsMock) FieldDescriptionsCalls() []struct {
}

FieldDescriptionsCalls gets all the calls that were made to FieldDescriptions. Check the length with:

len(mockedPGXRows.FieldDescriptionsCalls())

func (*PGXRowsMock) Next added in v0.10.0

func (mock *PGXRowsMock) Next() bool

Next calls NextFunc.

func (*PGXRowsMock) NextCalls added in v0.10.0

func (mock *PGXRowsMock) NextCalls() []struct {
}

NextCalls gets all the calls that were made to Next. Check the length with:

len(mockedPGXRows.NextCalls())

func (*PGXRowsMock) RawValues added in v0.10.0

func (mock *PGXRowsMock) RawValues() [][]byte

RawValues calls RawValuesFunc.

func (*PGXRowsMock) RawValuesCalls added in v0.10.0

func (mock *PGXRowsMock) RawValuesCalls() []struct {
}

RawValuesCalls gets all the calls that were made to RawValues. Check the length with:

len(mockedPGXRows.RawValuesCalls())

func (*PGXRowsMock) Scan added in v0.10.0

func (mock *PGXRowsMock) Scan(dest ...interface{}) error

Scan calls ScanFunc.

func (*PGXRowsMock) ScanCalls added in v0.10.0

func (mock *PGXRowsMock) ScanCalls() []struct {
	Dest []interface{}
}

ScanCalls gets all the calls that were made to Scan. Check the length with:

len(mockedPGXRows.ScanCalls())

func (*PGXRowsMock) Values added in v0.10.0

func (mock *PGXRowsMock) Values() ([]interface{}, error)

Values calls ValuesFunc.

func (*PGXRowsMock) ValuesCalls added in v0.10.0

func (mock *PGXRowsMock) ValuesCalls() []struct {
}

ValuesCalls gets all the calls that were made to Values. Check the length with:

len(mockedPGXRows.ValuesCalls())

type PGXTransactionMock added in v0.11.0

type PGXTransactionMock struct {
	// BeginMock mocks the Begin method.
	BeginMock func(ctx context.Context) (v4.Tx, error)

	// BeginFuncMock mocks the BeginFunc method.
	BeginFuncMock func(ctx context.Context, f func(v4.Tx) error) error

	// CommitFunc mocks the Commit method.
	CommitFunc func(ctx context.Context) error

	// ConnFunc mocks the Conn method.
	ConnFunc func() *v4.Conn

	// CopyFromFunc mocks the CopyFrom method.
	CopyFromFunc func(ctx context.Context, tableName v4.Identifier, columnNames []string, rowSrc v4.CopyFromSource) (int64, error)

	// ExecFunc mocks the Exec method.
	ExecFunc func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

	// LargeObjectsFunc mocks the LargeObjects method.
	LargeObjectsFunc func() v4.LargeObjects

	// PrepareFunc mocks the Prepare method.
	PrepareFunc func(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)

	// QueryFunc mocks the Query method.
	QueryMock func(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)

	// QueryFuncFunc mocks the QueryFunc method.
	QueryFuncMock func(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(v4.QueryFuncRow) error) (pgconn.CommandTag, error)

	// QueryRowFunc mocks the QueryRow method.
	QueryRowFunc func(ctx context.Context, sql string, args ...interface{}) v4.Row

	// RollbackFunc mocks the Rollback method.
	RollbackFunc func(ctx context.Context) error

	// SendBatchFunc mocks the SendBatch method.
	SendBatchFunc func(ctx context.Context, b *v4.Batch) v4.BatchResults
	// contains filtered or unexported fields
}

PGXTransactionMock is a mock implementation of pgx.PGXTransaction.

func TestSomethingThatUsesPGXTransaction(t *testing.T) {

	// make and configure a mocked pgx.PGXTransaction
	mockedPGXTransaction := &PGXTransactionMock{
		BeginFunc: func(ctx context.Context) (v4.Tx, error) {
			panic("mock out the Begin method")
		},
		BeginFuncFunc: func(ctx context.Context, f func(v4.Tx) error) error {
			panic("mock out the BeginFunc method")
		},
		CommitFunc: func(ctx context.Context) error {
			panic("mock out the Commit method")
		},
		ConnFunc: func() *v4.Conn {
			panic("mock out the Conn method")
		},
		CopyFromFunc: func(ctx context.Context, tableName v4.Identifier, columnNames []string, rowSrc v4.CopyFromSource) (int64, error) {
			panic("mock out the CopyFrom method")
		},
		ExecFunc: func(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) {
			panic("mock out the Exec method")
		},
		LargeObjectsFunc: func() v4.LargeObjects {
			panic("mock out the LargeObjects method")
		},
		PrepareFunc: func(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error) {
			panic("mock out the Prepare method")
		},
		QueryFunc: func(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error) {
			panic("mock out the Query method")
		},
		QueryFuncFunc: func(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(v4.QueryFuncRow) error) (pgconn.CommandTag, error) {
			panic("mock out the QueryFunc method")
		},
		QueryRowFunc: func(ctx context.Context, sql string, args ...interface{}) v4.Row {
			panic("mock out the QueryRow method")
		},
		RollbackFunc: func(ctx context.Context) error {
			panic("mock out the Rollback method")
		},
		SendBatchFunc: func(ctx context.Context, b *v4.Batch) v4.BatchResults {
			panic("mock out the SendBatch method")
		},
	}

	// use mockedPGXTransaction in code that requires pgx.PGXTransaction
	// and then make assertions.

}

func (*PGXTransactionMock) Begin added in v0.11.0

func (mock *PGXTransactionMock) Begin(ctx context.Context) (v4.Tx, error)

Begin calls BeginFunc.

func (*PGXTransactionMock) BeginCalls added in v0.11.0

func (mock *PGXTransactionMock) BeginCalls() []struct {
	Ctx context.Context
}

BeginCalls gets all the calls that were made to Begin. Check the length with:

len(mockedPGXTransaction.BeginCalls())

func (*PGXTransactionMock) BeginFunc added in v0.11.0

func (mock *PGXTransactionMock) BeginFunc(ctx context.Context, f func(v4.Tx) error) error

BeginFunc calls BeginFuncFunc.

func (*PGXTransactionMock) BeginFuncCalls added in v0.11.0

func (mock *PGXTransactionMock) BeginFuncCalls() []struct {
	Ctx context.Context
	F   func(v4.Tx) error
}

BeginFuncCalls gets all the calls that were made to BeginFunc. Check the length with:

len(mockedPGXTransaction.BeginFuncCalls())

func (*PGXTransactionMock) Commit added in v0.11.0

func (mock *PGXTransactionMock) Commit(ctx context.Context) error

Commit calls CommitFunc.

func (*PGXTransactionMock) CommitCalls added in v0.11.0

func (mock *PGXTransactionMock) CommitCalls() []struct {
	Ctx context.Context
}

CommitCalls gets all the calls that were made to Commit. Check the length with:

len(mockedPGXTransaction.CommitCalls())

func (*PGXTransactionMock) Conn added in v0.11.0

func (mock *PGXTransactionMock) Conn() *v4.Conn

Conn calls ConnFunc.

func (*PGXTransactionMock) ConnCalls added in v0.11.0

func (mock *PGXTransactionMock) ConnCalls() []struct {
}

ConnCalls gets all the calls that were made to Conn. Check the length with:

len(mockedPGXTransaction.ConnCalls())

func (*PGXTransactionMock) CopyFrom added in v0.11.0

func (mock *PGXTransactionMock) CopyFrom(ctx context.Context, tableName v4.Identifier, columnNames []string, rowSrc v4.CopyFromSource) (int64, error)

CopyFrom calls CopyFromFunc.

func (*PGXTransactionMock) CopyFromCalls added in v0.11.0

func (mock *PGXTransactionMock) CopyFromCalls() []struct {
	Ctx         context.Context
	TableName   v4.Identifier
	ColumnNames []string
	RowSrc      v4.CopyFromSource
}

CopyFromCalls gets all the calls that were made to CopyFrom. Check the length with:

len(mockedPGXTransaction.CopyFromCalls())

func (*PGXTransactionMock) Exec added in v0.11.0

func (mock *PGXTransactionMock) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

Exec calls ExecFunc.

func (*PGXTransactionMock) ExecCalls added in v0.11.0

func (mock *PGXTransactionMock) ExecCalls() []struct {
	Ctx       context.Context
	SQL       string
	Arguments []interface{}
}

ExecCalls gets all the calls that were made to Exec. Check the length with:

len(mockedPGXTransaction.ExecCalls())

func (*PGXTransactionMock) LargeObjects added in v0.11.0

func (mock *PGXTransactionMock) LargeObjects() v4.LargeObjects

LargeObjects calls LargeObjectsFunc.

func (*PGXTransactionMock) LargeObjectsCalls added in v0.11.0

func (mock *PGXTransactionMock) LargeObjectsCalls() []struct {
}

LargeObjectsCalls gets all the calls that were made to LargeObjects. Check the length with:

len(mockedPGXTransaction.LargeObjectsCalls())

func (*PGXTransactionMock) Prepare added in v0.11.0

func (mock *PGXTransactionMock) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error)

Prepare calls PrepareFunc.

func (*PGXTransactionMock) PrepareCalls added in v0.11.0

func (mock *PGXTransactionMock) PrepareCalls() []struct {
	Ctx  context.Context
	Name string
	SQL  string
}

PrepareCalls gets all the calls that were made to Prepare. Check the length with:

len(mockedPGXTransaction.PrepareCalls())

func (*PGXTransactionMock) Query added in v0.11.0

func (mock *PGXTransactionMock) Query(ctx context.Context, sql string, args ...interface{}) (v4.Rows, error)

Query calls QueryFunc.

func (*PGXTransactionMock) QueryCalls added in v0.11.0

func (mock *PGXTransactionMock) QueryCalls() []struct {
	Ctx  context.Context
	SQL  string
	Args []interface{}
}

QueryCalls gets all the calls that were made to Query. Check the length with:

len(mockedPGXTransaction.QueryCalls())

func (*PGXTransactionMock) QueryFunc added in v0.11.0

func (mock *PGXTransactionMock) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(v4.QueryFuncRow) error) (pgconn.CommandTag, error)

QueryFunc calls QueryFuncFunc.

func (*PGXTransactionMock) QueryFuncCalls added in v0.11.0

func (mock *PGXTransactionMock) QueryFuncCalls() []struct {
	Ctx   context.Context
	SQL   string
	Args  []interface{}
	Scans []interface{}
	F     func(v4.QueryFuncRow) error
}

QueryFuncCalls gets all the calls that were made to QueryFunc. Check the length with:

len(mockedPGXTransaction.QueryFuncCalls())

func (*PGXTransactionMock) QueryRow added in v0.11.0

func (mock *PGXTransactionMock) QueryRow(ctx context.Context, sql string, args ...interface{}) v4.Row

QueryRow calls QueryRowFunc.

func (*PGXTransactionMock) QueryRowCalls added in v0.11.0

func (mock *PGXTransactionMock) QueryRowCalls() []struct {
	Ctx  context.Context
	SQL  string
	Args []interface{}
}

QueryRowCalls gets all the calls that were made to QueryRow. Check the length with:

len(mockedPGXTransaction.QueryRowCalls())

func (*PGXTransactionMock) Rollback added in v0.11.0

func (mock *PGXTransactionMock) Rollback(ctx context.Context) error

Rollback calls RollbackFunc.

func (*PGXTransactionMock) RollbackCalls added in v0.11.0

func (mock *PGXTransactionMock) RollbackCalls() []struct {
	Ctx context.Context
}

RollbackCalls gets all the calls that were made to Rollback. Check the length with:

len(mockedPGXTransaction.RollbackCalls())

func (*PGXTransactionMock) SendBatch added in v0.11.0

func (mock *PGXTransactionMock) SendBatch(ctx context.Context, b *v4.Batch) v4.BatchResults

SendBatch calls SendBatchFunc.

func (*PGXTransactionMock) SendBatchCalls added in v0.11.0

func (mock *PGXTransactionMock) SendBatchCalls() []struct {
	Ctx context.Context
	B   *v4.Batch
}

SendBatchCalls gets all the calls that were made to SendBatch. Check the length with:

len(mockedPGXTransaction.SendBatchCalls())

Jump to

Keyboard shortcuts

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