Documentation ¶
Index ¶
- func SuppressNoRowsError(err error) error
- type Database
- type MockDatabase
- func (_m *MockDatabase) EXPECT() *MockDatabase_Expecter
- func (_m *MockDatabase) Exec(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (_m *MockDatabase) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (_m *MockDatabase) List(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (_m *MockDatabase) WithTx(ctx context.Context, txFn func(context.Context) error) error
- type MockDatabase_Exec_Call
- type MockDatabase_Expecter
- func (_e *MockDatabase_Expecter) Exec(ctx interface{}, dest interface{}, query interface{}, args ...interface{}) *MockDatabase_Exec_Call
- func (_e *MockDatabase_Expecter) Get(ctx interface{}, dest interface{}, query interface{}, args ...interface{}) *MockDatabase_Get_Call
- func (_e *MockDatabase_Expecter) List(ctx interface{}, dest interface{}, query interface{}, args ...interface{}) *MockDatabase_List_Call
- func (_e *MockDatabase_Expecter) WithTx(ctx interface{}, txFn interface{}) *MockDatabase_WithTx_Call
- type MockDatabase_Get_Call
- type MockDatabase_List_Call
- type MockDatabase_WithTx_Call
- func (_c *MockDatabase_WithTx_Call) Return(_a0 error) *MockDatabase_WithTx_Call
- func (_c *MockDatabase_WithTx_Call) Run(run func(ctx context.Context, txFn func(context.Context) error)) *MockDatabase_WithTx_Call
- func (_c *MockDatabase_WithTx_Call) RunAndReturn(run func(context.Context, func(context.Context) error) error) *MockDatabase_WithTx_Call
- type MockTransactor
- type MockTransactor_Expecter
- type MockTransactor_WithTx_Call
- func (_c *MockTransactor_WithTx_Call) Return(_a0 error) *MockTransactor_WithTx_Call
- func (_c *MockTransactor_WithTx_Call) Run(run func(ctx context.Context, txFn func(context.Context) error)) *MockTransactor_WithTx_Call
- func (_c *MockTransactor_WithTx_Call) RunAndReturn(run func(context.Context, func(context.Context) error) error) *MockTransactor_WithTx_Call
- type Transactor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SuppressNoRowsError ¶
SuppressNoRowsError suppresses the sql.ErrNoRows error.
Types ¶
type Database ¶
type Database interface { // Exec executes a query. Should be used for write operations. // When used inside WithTx, the query is executed within the transaction. // If dest is nil, the query is executed without expecting any result. // If dest is a pointer to a slice or an array, the query is executed and the result is stored in the slice or array. // If dest is a pointer to a struct, the query is executed and the result is stored in the struct. Exec(ctx context.Context, dest any, query string, args ...any) error // Get executes a query that is expected to return at most one row. Should be used for read operations. // When used inside WithTx, the query is executed within the transaction. // The result is stored in the dest. Get(ctx context.Context, dest any, query string, args ...any) error // List executes a query that is expected to return multiple rows. Should be used for read operations. // When used inside WithTx, the query is executed within the transaction. // The result is stored in the dest. List(ctx context.Context, dest any, query string, args ...any) error Transactor }
Database is an interface that defines the methods that a database should implement.
func NewPostgresDatabase ¶
NewPostgresDatabase creates a new instance of the postgresDatabase. Currently we are executing the queries directly. The idea to use different connections for read and write operations. The Exec method will be used for write operations. Get & Select methods will be used for readonly operations.
type MockDatabase ¶
MockDatabase is an autogenerated mock type for the Database type
func NewMockDatabase ¶
func NewMockDatabase(t interface { mock.TestingT Cleanup(func()) }) *MockDatabase
NewMockDatabase creates a new instance of MockDatabase. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockDatabase) EXPECT ¶
func (_m *MockDatabase) EXPECT() *MockDatabase_Expecter
func (*MockDatabase) Exec ¶
func (_m *MockDatabase) Exec(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Exec provides a mock function with given fields: ctx, dest, query, args
func (*MockDatabase) Get ¶
func (_m *MockDatabase) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Get provides a mock function with given fields: ctx, dest, query, args
type MockDatabase_Exec_Call ¶
MockDatabase_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec'
func (*MockDatabase_Exec_Call) Return ¶
func (_c *MockDatabase_Exec_Call) Return(_a0 error) *MockDatabase_Exec_Call
func (*MockDatabase_Exec_Call) Run ¶
func (_c *MockDatabase_Exec_Call) Run(run func(ctx context.Context, dest interface{}, query string, args ...interface{})) *MockDatabase_Exec_Call
func (*MockDatabase_Exec_Call) RunAndReturn ¶
func (_c *MockDatabase_Exec_Call) RunAndReturn(run func(context.Context, interface{}, string, ...interface{}) error) *MockDatabase_Exec_Call
type MockDatabase_Expecter ¶
type MockDatabase_Expecter struct {
// contains filtered or unexported fields
}
func (*MockDatabase_Expecter) Exec ¶
func (_e *MockDatabase_Expecter) Exec(ctx interface{}, dest interface{}, query interface{}, args ...interface{}) *MockDatabase_Exec_Call
Exec is a helper method to define mock.On call
- ctx context.Context
- dest interface{}
- query string
- args ...interface{}
func (*MockDatabase_Expecter) Get ¶
func (_e *MockDatabase_Expecter) Get(ctx interface{}, dest interface{}, query interface{}, args ...interface{}) *MockDatabase_Get_Call
Get is a helper method to define mock.On call
- ctx context.Context
- dest interface{}
- query string
- args ...interface{}
func (*MockDatabase_Expecter) List ¶
func (_e *MockDatabase_Expecter) List(ctx interface{}, dest interface{}, query interface{}, args ...interface{}) *MockDatabase_List_Call
List is a helper method to define mock.On call
- ctx context.Context
- dest interface{}
- query string
- args ...interface{}
func (*MockDatabase_Expecter) WithTx ¶
func (_e *MockDatabase_Expecter) WithTx(ctx interface{}, txFn interface{}) *MockDatabase_WithTx_Call
WithTx is a helper method to define mock.On call
- ctx context.Context
- txFn func(context.Context) error
type MockDatabase_Get_Call ¶
MockDatabase_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
func (*MockDatabase_Get_Call) Return ¶
func (_c *MockDatabase_Get_Call) Return(_a0 error) *MockDatabase_Get_Call
func (*MockDatabase_Get_Call) Run ¶
func (_c *MockDatabase_Get_Call) Run(run func(ctx context.Context, dest interface{}, query string, args ...interface{})) *MockDatabase_Get_Call
func (*MockDatabase_Get_Call) RunAndReturn ¶
func (_c *MockDatabase_Get_Call) RunAndReturn(run func(context.Context, interface{}, string, ...interface{}) error) *MockDatabase_Get_Call
type MockDatabase_List_Call ¶
MockDatabase_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'
func (*MockDatabase_List_Call) Return ¶
func (_c *MockDatabase_List_Call) Return(_a0 error) *MockDatabase_List_Call
func (*MockDatabase_List_Call) Run ¶
func (_c *MockDatabase_List_Call) Run(run func(ctx context.Context, dest interface{}, query string, args ...interface{})) *MockDatabase_List_Call
func (*MockDatabase_List_Call) RunAndReturn ¶
func (_c *MockDatabase_List_Call) RunAndReturn(run func(context.Context, interface{}, string, ...interface{}) error) *MockDatabase_List_Call
type MockDatabase_WithTx_Call ¶
MockDatabase_WithTx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithTx'
func (*MockDatabase_WithTx_Call) Return ¶
func (_c *MockDatabase_WithTx_Call) Return(_a0 error) *MockDatabase_WithTx_Call
func (*MockDatabase_WithTx_Call) Run ¶
func (_c *MockDatabase_WithTx_Call) Run(run func(ctx context.Context, txFn func(context.Context) error)) *MockDatabase_WithTx_Call
func (*MockDatabase_WithTx_Call) RunAndReturn ¶
func (_c *MockDatabase_WithTx_Call) RunAndReturn(run func(context.Context, func(context.Context) error) error) *MockDatabase_WithTx_Call
type MockTransactor ¶
MockTransactor is an autogenerated mock type for the Transactor type
func NewMockTransactor ¶
func NewMockTransactor(t interface { mock.TestingT Cleanup(func()) }) *MockTransactor
NewMockTransactor creates a new instance of MockTransactor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockTransactor) EXPECT ¶
func (_m *MockTransactor) EXPECT() *MockTransactor_Expecter
type MockTransactor_Expecter ¶
type MockTransactor_Expecter struct {
// contains filtered or unexported fields
}
func (*MockTransactor_Expecter) WithTx ¶
func (_e *MockTransactor_Expecter) WithTx(ctx interface{}, txFn interface{}) *MockTransactor_WithTx_Call
WithTx is a helper method to define mock.On call
- ctx context.Context
- txFn func(context.Context) error
type MockTransactor_WithTx_Call ¶
MockTransactor_WithTx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithTx'
func (*MockTransactor_WithTx_Call) Return ¶
func (_c *MockTransactor_WithTx_Call) Return(_a0 error) *MockTransactor_WithTx_Call
func (*MockTransactor_WithTx_Call) Run ¶
func (_c *MockTransactor_WithTx_Call) Run(run func(ctx context.Context, txFn func(context.Context) error)) *MockTransactor_WithTx_Call
func (*MockTransactor_WithTx_Call) RunAndReturn ¶
func (_c *MockTransactor_WithTx_Call) RunAndReturn(run func(context.Context, func(context.Context) error) error) *MockTransactor_WithTx_Call