Documentation
¶
Overview ¶
Package mockdatabase provides moq-generated mocks for the database package.
Index ¶
- type ClientMock
- func (mock *ClientMock) Close() error
- func (mock *ClientMock) CloseCalls() []struct{}
- func (mock *ClientMock) CurrentTime() time.Time
- func (mock *ClientMock) CurrentTimeCalls() []struct{}
- func (mock *ClientMock) ReadDB() *sql.DB
- func (mock *ClientMock) ReadDBCalls() []struct{}
- func (mock *ClientMock) RollbackTransaction(ctx context.Context, tx database.SQLQueryExecutorAndTransactionManager)
- func (mock *ClientMock) RollbackTransactionCalls() []struct{ ... }
- func (mock *ClientMock) WriteDB() *sql.DB
- func (mock *ClientMock) WriteDBCalls() []struct{}
- type ResultIteratorMock
- func (mock *ResultIteratorMock) Close() error
- func (mock *ResultIteratorMock) CloseCalls() []struct{}
- func (mock *ResultIteratorMock) Err() error
- func (mock *ResultIteratorMock) ErrCalls() []struct{}
- func (mock *ResultIteratorMock) Next() bool
- func (mock *ResultIteratorMock) NextCalls() []struct{}
- func (mock *ResultIteratorMock) Scan(dest ...any) error
- func (mock *ResultIteratorMock) ScanCalls() []struct{ ... }
- type SQLQueryExecutorMock
- func (mock *SQLQueryExecutorMock) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (mock *SQLQueryExecutorMock) ExecContextCalls() []struct{ ... }
- func (mock *SQLQueryExecutorMock) PrepareContext(contextMoqParam context.Context, s string) (*sql.Stmt, error)
- func (mock *SQLQueryExecutorMock) PrepareContextCalls() []struct{ ... }
- func (mock *SQLQueryExecutorMock) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (mock *SQLQueryExecutorMock) QueryContextCalls() []struct{ ... }
- func (mock *SQLQueryExecutorMock) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- func (mock *SQLQueryExecutorMock) QueryRowContextCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientMock ¶
type ClientMock struct {
// CloseFunc mocks the Close method.
CloseFunc func() error
// CurrentTimeFunc mocks the CurrentTime method.
CurrentTimeFunc func() time.Time
// ReadDBFunc mocks the ReadDB method.
ReadDBFunc func() *sql.DB
// RollbackTransactionFunc mocks the RollbackTransaction method.
RollbackTransactionFunc func(ctx context.Context, tx database.SQLQueryExecutorAndTransactionManager)
// WriteDBFunc mocks the WriteDB method.
WriteDBFunc func() *sql.DB
// contains filtered or unexported fields
}
ClientMock is a mock implementation of database.Client.
func TestSomethingThatUsesClient(t *testing.T) {
// make and configure a mocked database.Client
mockedClient := &ClientMock{
CloseFunc: func() error {
panic("mock out the Close method")
},
CurrentTimeFunc: func() time.Time {
panic("mock out the CurrentTime method")
},
ReadDBFunc: func() *sql.DB {
panic("mock out the ReadDB method")
},
RollbackTransactionFunc: func(ctx context.Context, tx database.SQLQueryExecutorAndTransactionManager) {
panic("mock out the RollbackTransaction method")
},
WriteDBFunc: func() *sql.DB {
panic("mock out the WriteDB method")
},
}
// use mockedClient in code that requires database.Client
// and then make assertions.
}
func (*ClientMock) CloseCalls ¶
func (mock *ClientMock) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedClient.CloseCalls())
func (*ClientMock) CurrentTime ¶
func (mock *ClientMock) CurrentTime() time.Time
CurrentTime calls CurrentTimeFunc.
func (*ClientMock) CurrentTimeCalls ¶
func (mock *ClientMock) CurrentTimeCalls() []struct { }
CurrentTimeCalls gets all the calls that were made to CurrentTime. Check the length with:
len(mockedClient.CurrentTimeCalls())
func (*ClientMock) ReadDBCalls ¶
func (mock *ClientMock) ReadDBCalls() []struct { }
ReadDBCalls gets all the calls that were made to ReadDB. Check the length with:
len(mockedClient.ReadDBCalls())
func (*ClientMock) RollbackTransaction ¶
func (mock *ClientMock) RollbackTransaction(ctx context.Context, tx database.SQLQueryExecutorAndTransactionManager)
RollbackTransaction calls RollbackTransactionFunc.
func (*ClientMock) RollbackTransactionCalls ¶
func (mock *ClientMock) RollbackTransactionCalls() []struct { Ctx context.Context Tx database.SQLQueryExecutorAndTransactionManager }
RollbackTransactionCalls gets all the calls that were made to RollbackTransaction. Check the length with:
len(mockedClient.RollbackTransactionCalls())
func (*ClientMock) WriteDBCalls ¶
func (mock *ClientMock) WriteDBCalls() []struct { }
WriteDBCalls gets all the calls that were made to WriteDB. Check the length with:
len(mockedClient.WriteDBCalls())
type ResultIteratorMock ¶
type ResultIteratorMock struct {
// CloseFunc mocks the Close method.
CloseFunc func() error
// ErrFunc mocks the Err method.
ErrFunc func() error
// NextFunc mocks the Next method.
NextFunc func() bool
// ScanFunc mocks the Scan method.
ScanFunc func(dest ...any) error
// contains filtered or unexported fields
}
ResultIteratorMock is a mock implementation of database.ResultIterator.
func TestSomethingThatUsesResultIterator(t *testing.T) {
// make and configure a mocked database.ResultIterator
mockedResultIterator := &ResultIteratorMock{
CloseFunc: func() error {
panic("mock out the Close method")
},
ErrFunc: func() error {
panic("mock out the Err method")
},
NextFunc: func() bool {
panic("mock out the Next method")
},
ScanFunc: func(dest ...any) error {
panic("mock out the Scan method")
},
}
// use mockedResultIterator in code that requires database.ResultIterator
// and then make assertions.
}
func (*ResultIteratorMock) Close ¶
func (mock *ResultIteratorMock) Close() error
Close calls CloseFunc.
func (*ResultIteratorMock) CloseCalls ¶
func (mock *ResultIteratorMock) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedResultIterator.CloseCalls())
func (*ResultIteratorMock) ErrCalls ¶
func (mock *ResultIteratorMock) ErrCalls() []struct { }
ErrCalls gets all the calls that were made to Err. Check the length with:
len(mockedResultIterator.ErrCalls())
func (*ResultIteratorMock) NextCalls ¶
func (mock *ResultIteratorMock) NextCalls() []struct { }
NextCalls gets all the calls that were made to Next. Check the length with:
len(mockedResultIterator.NextCalls())
func (*ResultIteratorMock) Scan ¶
func (mock *ResultIteratorMock) Scan(dest ...any) error
Scan calls ScanFunc.
func (*ResultIteratorMock) ScanCalls ¶
func (mock *ResultIteratorMock) ScanCalls() []struct { Dest []any }
ScanCalls gets all the calls that were made to Scan. Check the length with:
len(mockedResultIterator.ScanCalls())
type SQLQueryExecutorMock ¶
type SQLQueryExecutorMock struct {
// ExecContextFunc mocks the ExecContext method.
ExecContextFunc func(ctx context.Context, query string, args ...any) (sql.Result, error)
// PrepareContextFunc mocks the PrepareContext method.
PrepareContextFunc func(contextMoqParam context.Context, s string) (*sql.Stmt, error)
// QueryContextFunc mocks the QueryContext method.
QueryContextFunc func(ctx context.Context, query string, args ...any) (*sql.Rows, error)
// QueryRowContextFunc mocks the QueryRowContext method.
QueryRowContextFunc func(ctx context.Context, query string, args ...any) *sql.Row
// contains filtered or unexported fields
}
SQLQueryExecutorMock is a mock implementation of database.SQLQueryExecutor.
func TestSomethingThatUsesSQLQueryExecutor(t *testing.T) {
// make and configure a mocked database.SQLQueryExecutor
mockedSQLQueryExecutor := &SQLQueryExecutorMock{
ExecContextFunc: func(ctx context.Context, query string, args ...any) (sql.Result, error) {
panic("mock out the ExecContext method")
},
PrepareContextFunc: func(contextMoqParam context.Context, s string) (*sql.Stmt, error) {
panic("mock out the PrepareContext method")
},
QueryContextFunc: func(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
panic("mock out the QueryContext method")
},
QueryRowContextFunc: func(ctx context.Context, query string, args ...any) *sql.Row {
panic("mock out the QueryRowContext method")
},
}
// use mockedSQLQueryExecutor in code that requires database.SQLQueryExecutor
// and then make assertions.
}
func (*SQLQueryExecutorMock) ExecContext ¶
func (mock *SQLQueryExecutorMock) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
ExecContext calls ExecContextFunc.
func (*SQLQueryExecutorMock) ExecContextCalls ¶
func (mock *SQLQueryExecutorMock) ExecContextCalls() []struct { Ctx context.Context Query string Args []any }
ExecContextCalls gets all the calls that were made to ExecContext. Check the length with:
len(mockedSQLQueryExecutor.ExecContextCalls())
func (*SQLQueryExecutorMock) PrepareContext ¶
func (mock *SQLQueryExecutorMock) PrepareContext(contextMoqParam context.Context, s string) (*sql.Stmt, error)
PrepareContext calls PrepareContextFunc.
func (*SQLQueryExecutorMock) PrepareContextCalls ¶
func (mock *SQLQueryExecutorMock) PrepareContextCalls() []struct { ContextMoqParam context.Context S string }
PrepareContextCalls gets all the calls that were made to PrepareContext. Check the length with:
len(mockedSQLQueryExecutor.PrepareContextCalls())
func (*SQLQueryExecutorMock) QueryContext ¶
func (mock *SQLQueryExecutorMock) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryContext calls QueryContextFunc.
func (*SQLQueryExecutorMock) QueryContextCalls ¶
func (mock *SQLQueryExecutorMock) QueryContextCalls() []struct { Ctx context.Context Query string Args []any }
QueryContextCalls gets all the calls that were made to QueryContext. Check the length with:
len(mockedSQLQueryExecutor.QueryContextCalls())
func (*SQLQueryExecutorMock) QueryRowContext ¶
func (mock *SQLQueryExecutorMock) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
QueryRowContext calls QueryRowContextFunc.
func (*SQLQueryExecutorMock) QueryRowContextCalls ¶
func (mock *SQLQueryExecutorMock) QueryRowContextCalls() []struct { Ctx context.Context Query string Args []any }
QueryRowContextCalls gets all the calls that were made to QueryRowContext. Check the length with:
len(mockedSQLQueryExecutor.QueryRowContextCalls())