mock

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 4 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()

	// 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")
		},
		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) 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())

Jump to

Keyboard shortcuts

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