Documentation
¶
Index ¶
- func NewClickHouseNative(options *clickhouse.Options) (*clickhousemock, error)
- func NewClickHouseWithQueryMatcher(options *clickhouse.Options, queryMatcher sqlmock.QueryMatcher) (*clickhousemock, error)
- func NewColumnType(name string, chType string, nullable bool, scanType reflect.Type) driver.ColumnType
- type ClickConnMockCommon
- type ColumnType
- type ExpectedAbort
- type ExpectedAppend
- type ExpectedAppendStruct
- type ExpectedAsyncInsert
- type ExpectedClose
- type ExpectedColumn
- type ExpectedContributors
- type ExpectedExec
- type ExpectedFlush
- type ExpectedIsSent
- type ExpectedPing
- type ExpectedPrepareBatch
- func (e *ExpectedPrepareBatch) ExpectAbort() *ExpectedAbort
- func (e *ExpectedPrepareBatch) ExpectAppend() *ExpectedAppend
- func (e *ExpectedPrepareBatch) ExpectAppendStruct() *ExpectedAppendStruct
- func (e *ExpectedPrepareBatch) ExpectColumn() *ExpectedColumn
- func (e *ExpectedPrepareBatch) ExpectFlush() *ExpectedFlush
- func (e *ExpectedPrepareBatch) ExpectIsSent() *ExpectedIsSent
- func (e *ExpectedPrepareBatch) ExpectSend() *ExpectedSend
- func (e *ExpectedPrepareBatch) String() string
- func (e *ExpectedPrepareBatch) WillBeSent() *ExpectedPrepareBatch
- func (e *ExpectedPrepareBatch) WillDelayFor(duration time.Duration) *ExpectedPrepareBatch
- func (e *ExpectedPrepareBatch) WillReturnError(err error) *ExpectedPrepareBatch
- func (e *ExpectedPrepareBatch) WillReturnRows(rows int) *ExpectedPrepareBatch
- type ExpectedQuery
- func (e *ExpectedQuery) RowsWillBeClosed() *ExpectedQuery
- func (e *ExpectedQuery) String() string
- func (e *ExpectedQuery) WillDelayFor(duration time.Duration) *ExpectedQuery
- func (e *ExpectedQuery) WillReturnError(err error) *ExpectedQuery
- func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery
- func (e *ExpectedQuery) WithArgs(args ...any) *ExpectedQuery
- type ExpectedQueryRow
- type ExpectedSelect
- type ExpectedSend
- type ExpectedServerVersion
- type ExpectedStats
- type OpError
- type Row
- type Rows
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClickHouseNative ¶
func NewClickHouseNative(options *clickhouse.Options) (*clickhousemock, error)
NewClickHouseNative creates clickhousemock database mock to manage expectations.
func NewClickHouseWithQueryMatcher ¶ added in v0.6.0
func NewClickHouseWithQueryMatcher( options *clickhouse.Options, queryMatcher sqlmock.QueryMatcher, ) (*clickhousemock, error)
func NewColumnType ¶
Types ¶
type ClickConnMockCommon ¶
type ClickConnMockCommon interface { // ExpectClose queues an expectation for this database // action to be triggered. the *ExpectedClose allows // to mock database response ExpectClose() *ExpectedClose // ExpectStats queues an expectation for this database // action to be triggered. the *ExpectedStats allows // to mock database response ExpectStats() *ExpectedStats // ExpectPing expects *driver.Conn.Ping to be called. // the *ExpectedPing allows to mock database response ExpectPing() *ExpectedPing // ExpectAsyncInsert expects *driver.Conn.AsyncInsert to be called. // the *ExpectedAsyncInsert allows to mock database response ExpectAsyncInsert(expectedSQL string, expectedWait bool) *ExpectedAsyncInsert // ExpectExec expects Exec() to be called with expectedSQL query. // the *ExpectedExec allows to mock database response ExpectExec(expectedSQL string) *ExpectedExec // ExpectPrepareBatch expects PrepareBatch() to be called with expectedSQL query. // the *ExpectedPrepareBatch allows to mock database response. // Note that you may expect Append() or AppendStruct() on the *ExpectedPrepareBatch // statement to prevent repeating expectedSQL ExpectPrepareBatch(expectedSQL string) *ExpectedPrepareBatch // ExpectQueryRow expects QueryRow() to be called with expectedSQL query. // the *ExpectedQuery allows to mock database response. ExpectQueryRow(expectedSQL string) *ExpectedQueryRow // ExpectQuery expects Query() to be called with expectedSQL query. // the *ExpectedQuery allows to mock database response. ExpectQuery(expectedSQL string) *ExpectedQuery // ExpectSelect expects Select() to be called with expectedSQL query. // the *ExpectedSelect allows to mock database response. ExpectSelect(expectedSQL string) *ExpectedSelect // ExpectServerVersion queues an expectation for this database // action to be triggered. the *ExpectedServerVersion allows // to mock database response ExpectServerVersion() *ExpectedServerVersion // ExpectContributors queues an expectation for this database // action to be triggered. the *ExpectedContributors allows // to mock database response ExpectContributors() *ExpectedContributors // ExpectationsWereMet checks whether all queued expectations // were met in order. If any of them was not met - an error is returned. ExpectationsWereMet() error // MatchExpectationsInOrder gives an option whether to match all // expectations in the order they were set or not. // // By default it is set to true. But if you use goroutines // to parallelize your query executation, that option may // be handy. // // This option may be turned on anytime during tests. As soon // as it is switched to false, expectations will be matched // in any order. Or otherwise if switched to true, any unmatched // expectations will be expected in order MatchExpectationsInOrder(bool) }
ClickConnMockCommon interface serves to create expectations for any kind of database action in order to mock and test real database behavior.
type ColumnType ¶ added in v0.2.0
type ExpectedAbort ¶
type ExpectedAbort struct {
// contains filtered or unexported fields
}
func (*ExpectedAbort) String ¶
func (e *ExpectedAbort) String() string
func (*ExpectedAbort) WillReturnError ¶
func (e *ExpectedAbort) WillReturnError(err error) *ExpectedAbort
WillReturnError allows to set an error for the expected *batch.Abort action.
type ExpectedAppend ¶
type ExpectedAppend struct {
// contains filtered or unexported fields
}
func (*ExpectedAppend) String ¶
func (e *ExpectedAppend) String() string
func (*ExpectedAppend) WillReturnError ¶
func (e *ExpectedAppend) WillReturnError(err error) *ExpectedAppend
WillReturnError allows to set an error for the expected *batch.Append action.
type ExpectedAppendStruct ¶
type ExpectedAppendStruct struct {
// contains filtered or unexported fields
}
func (*ExpectedAppendStruct) String ¶
func (e *ExpectedAppendStruct) String() string
func (*ExpectedAppendStruct) WillReturnError ¶
func (e *ExpectedAppendStruct) WillReturnError(err error) *ExpectedAppendStruct
WillReturnError allows to set an error for the expected *batch.AppendStruct action.
type ExpectedAsyncInsert ¶
type ExpectedAsyncInsert struct {
// contains filtered or unexported fields
}
func (*ExpectedAsyncInsert) String ¶
func (e *ExpectedAsyncInsert) String() string
func (*ExpectedAsyncInsert) WillDelay ¶
func (e *ExpectedAsyncInsert) WillDelay(d time.Duration) *ExpectedAsyncInsert
WillDelay allows to set a delay for the expected *Conn.AsyncInsert action.
func (*ExpectedAsyncInsert) WillReturnError ¶
func (e *ExpectedAsyncInsert) WillReturnError(err error) *ExpectedAsyncInsert
WillReturnError allows to set an error for the expected *Conn.AsyncInsert action.
func (*ExpectedAsyncInsert) WillWait ¶
func (e *ExpectedAsyncInsert) WillWait() *ExpectedAsyncInsert
WillWait allows to set a wait for the expected *Conn.AsyncInsert action.
type ExpectedClose ¶
type ExpectedClose struct {
// contains filtered or unexported fields
}
ExpectedClose is used to manage *driver.Conn.Close expectation returned by *clickhousemock.ExpectClose.
func (*ExpectedClose) String ¶
func (e *ExpectedClose) String() string
String returns string representation
func (*ExpectedClose) WillReturnError ¶
func (e *ExpectedClose) WillReturnError(err error) *ExpectedClose
WillReturnError allows to set an error for *driver.Conn.Close action
type ExpectedColumn ¶
type ExpectedColumn struct {
// contains filtered or unexported fields
}
func (*ExpectedColumn) String ¶
func (e *ExpectedColumn) String() string
func (*ExpectedColumn) WillReturnBatchColumn ¶
func (e *ExpectedColumn) WillReturnBatchColumn(batchcolumn clikhouseDriver.BatchColumn) *ExpectedColumn
WillReturnBatchColumn allows to set an error for the expected *batch.Column action.
type ExpectedContributors ¶
type ExpectedContributors struct {
// contains filtered or unexported fields
}
func (*ExpectedContributors) String ¶
func (e *ExpectedContributors) String() string
func (*ExpectedContributors) WillReturnContributors ¶
func (e *ExpectedContributors) WillReturnContributors(contributors ...string) *ExpectedContributors
WillReturnContributors allows to set an error for the expected *Conn.Contributors action.
type ExpectedExec ¶
type ExpectedExec struct {
// contains filtered or unexported fields
}
ExpectedExec is used to manage *driver.Conn.Exec expectations. Returned by *clickhousemock.ExpectExec.
func (*ExpectedExec) String ¶
func (e *ExpectedExec) String() string
String returns string representation
func (*ExpectedExec) WillDelayFor ¶
func (e *ExpectedExec) WillDelayFor(duration time.Duration) *ExpectedExec
WillDelayFor allows to specify duration for which it will delay result. May be used together with Context
func (*ExpectedExec) WillReturnError ¶
func (e *ExpectedExec) WillReturnError(err error) *ExpectedExec
WillReturnError allows to set an error for expected database exec action
func (*ExpectedExec) WithArgs ¶
func (e *ExpectedExec) WithArgs(args ...any) *ExpectedExec
WithArgs will match given expected args to actual database exec operation arguments. if at least one argument does not match, it will return an error. For specific arguments an clickhousemock.Argument interface can be used to match an argument.
type ExpectedFlush ¶
type ExpectedFlush struct {
// contains filtered or unexported fields
}
func (*ExpectedFlush) String ¶
func (e *ExpectedFlush) String() string
func (*ExpectedFlush) WillReturnError ¶
func (e *ExpectedFlush) WillReturnError(err error) *ExpectedFlush
WillReturnError allows to set an error for the expected *batch.Flush action.
type ExpectedIsSent ¶
type ExpectedIsSent struct {
// contains filtered or unexported fields
}
func (*ExpectedIsSent) String ¶
func (e *ExpectedIsSent) String() string
func (*ExpectedIsSent) WillReturnBool ¶
func (e *ExpectedIsSent) WillReturnBool(b bool) *ExpectedIsSent
WillReturnBool allows to set an bool for the expected *batch.IsSent action.
type ExpectedPing ¶
type ExpectedPing struct {
// contains filtered or unexported fields
}
ExpectedPing is used to manage *driver.Conn.Ping expectations. Returned by *clickhousemock.ExpectPing.
func (*ExpectedPing) String ¶
func (e *ExpectedPing) String() string
String returns string representation
func (*ExpectedPing) WillDelayFor ¶
func (e *ExpectedPing) WillDelayFor(duration time.Duration) *ExpectedPing
WillDelayFor allows to specify duration for which it will delay result. May be used together with Context.
func (*ExpectedPing) WillReturnError ¶
func (e *ExpectedPing) WillReturnError(err error) *ExpectedPing
WillReturnError allows to set an error for expected database ping
type ExpectedPrepareBatch ¶
type ExpectedPrepareBatch struct {
// contains filtered or unexported fields
}
ExpectedPrepareBatch is used to manage *driver.Conn.PrepareBatch expectations. Returned by *clickhousemock.ExpectedPrepareBatch.
func (*ExpectedPrepareBatch) ExpectAbort ¶
func (e *ExpectedPrepareBatch) ExpectAbort() *ExpectedAbort
ExpectAbort allows to expect Abort() on this prepared batch statement.
func (*ExpectedPrepareBatch) ExpectAppend ¶
func (e *ExpectedPrepareBatch) ExpectAppend() *ExpectedAppend
ExpectAppend allows to expect Append() on this prepared batch statement. This method is convenient in order to prevent duplicating sql query string matching.
func (*ExpectedPrepareBatch) ExpectAppendStruct ¶
func (e *ExpectedPrepareBatch) ExpectAppendStruct() *ExpectedAppendStruct
ExpectAppendStruct allows to expect AppendStruct() on this prepared batch statement.
func (*ExpectedPrepareBatch) ExpectColumn ¶
func (e *ExpectedPrepareBatch) ExpectColumn() *ExpectedColumn
ExpectColumn allows to expect Column() on this prepared batch statement.
func (*ExpectedPrepareBatch) ExpectFlush ¶
func (e *ExpectedPrepareBatch) ExpectFlush() *ExpectedFlush
ExpectFlush allows to expect Flush() on this prepared batch statement.
func (*ExpectedPrepareBatch) ExpectIsSent ¶
func (e *ExpectedPrepareBatch) ExpectIsSent() *ExpectedIsSent
ExpectIsSent allows to expect IsSent() on this prepared batch statement.
func (*ExpectedPrepareBatch) ExpectSend ¶
func (e *ExpectedPrepareBatch) ExpectSend() *ExpectedSend
ExpectSend allows to expect Send() on this prepared batch statement.
func (*ExpectedPrepareBatch) String ¶
func (e *ExpectedPrepareBatch) String() string
String returns string representation
func (*ExpectedPrepareBatch) WillBeSent ¶
func (e *ExpectedPrepareBatch) WillBeSent() *ExpectedPrepareBatch
WillBeSent expects this prepared batch statement to be set with sent.
func (*ExpectedPrepareBatch) WillDelayFor ¶
func (e *ExpectedPrepareBatch) WillDelayFor(duration time.Duration) *ExpectedPrepareBatch
WillDelayFor allows to specify duration for which it will delay result. May be used together with Context
func (*ExpectedPrepareBatch) WillReturnError ¶
func (e *ExpectedPrepareBatch) WillReturnError(err error) *ExpectedPrepareBatch
WillReturnError allows to set an error for the expected *driver.Conn.PrepareBatch action.
func (*ExpectedPrepareBatch) WillReturnRows ¶
func (e *ExpectedPrepareBatch) WillReturnRows(rows int) *ExpectedPrepareBatch
WillReturnRows expects this prepared batch statement to be set with rows.
type ExpectedQuery ¶
type ExpectedQuery struct {
// contains filtered or unexported fields
}
ExpectedQuery is used to manage *driver.Conn.Query expectations. Returned by *clickhousemock.ExpectQuery.
func (*ExpectedQuery) RowsWillBeClosed ¶
func (e *ExpectedQuery) RowsWillBeClosed() *ExpectedQuery
RowsWillBeClosed expects this query rows to be closed.
func (*ExpectedQuery) String ¶
func (e *ExpectedQuery) String() string
String returns string representation
func (*ExpectedQuery) WillDelayFor ¶
func (e *ExpectedQuery) WillDelayFor(duration time.Duration) *ExpectedQuery
WillDelayFor allows to specify duration for which it will delay result. May be used together with Context
func (*ExpectedQuery) WillReturnError ¶
func (e *ExpectedQuery) WillReturnError(err error) *ExpectedQuery
WillReturnError allows to set an error for expected database query
func (*ExpectedQuery) WillReturnRows ¶
func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery
WillReturnRows allows to set rows for expected database query
func (*ExpectedQuery) WithArgs ¶
func (e *ExpectedQuery) WithArgs(args ...any) *ExpectedQuery
WithArgs will match given expected args to actual database query arguments. if at least one argument does not match, it will return an error. For specific arguments an clickhousemock.Argument interface can be used to match an argument.
type ExpectedQueryRow ¶
type ExpectedQueryRow struct {
// contains filtered or unexported fields
}
func (*ExpectedQueryRow) String ¶
func (e *ExpectedQueryRow) String() string
func (*ExpectedQueryRow) WillDelay ¶
func (e *ExpectedQueryRow) WillDelay(d time.Duration) *ExpectedQueryRow
WillDelay allows to set a delay for the expected *Conn.QueryRow action.
func (*ExpectedQueryRow) WillReturnRow ¶
func (e *ExpectedQueryRow) WillReturnRow(row *Row) *ExpectedQueryRow
WillReturnRow allows to set a row for the expected *Conn.QueryRow action.
type ExpectedSelect ¶
type ExpectedSelect struct {
// contains filtered or unexported fields
}
func (*ExpectedSelect) String ¶
func (e *ExpectedSelect) String() string
func (*ExpectedSelect) WillDelay ¶
func (e *ExpectedSelect) WillDelay(d time.Duration) *ExpectedSelect
WillDelay allows to set a delay for the expected *Conn.Select action.
func (*ExpectedSelect) WillReturnError ¶
func (e *ExpectedSelect) WillReturnError(err error) *ExpectedSelect
WillReturnError allows to set an error for the expected *Conn.Select action.
func (*ExpectedSelect) WillReturnRows ¶ added in v0.8.0
func (e *ExpectedSelect) WillReturnRows(rows *Rows) *ExpectedSelect
type ExpectedSend ¶
type ExpectedSend struct {
// contains filtered or unexported fields
}
func (*ExpectedSend) String ¶
func (e *ExpectedSend) String() string
func (*ExpectedSend) WillReturnError ¶
func (e *ExpectedSend) WillReturnError(err error) *ExpectedSend
WillReturnError allows to set an error for the expected *batch.Send action.
type ExpectedServerVersion ¶
type ExpectedServerVersion struct {
// contains filtered or unexported fields
}
func (*ExpectedServerVersion) String ¶
func (e *ExpectedServerVersion) String() string
func (*ExpectedServerVersion) WillReturnVersion ¶
func (e *ExpectedServerVersion) WillReturnVersion(version proto.ServerHandshake) *ExpectedServerVersion
WillReturnVersion allows to set an error for the expected *Conn.ServerVersion action.
type ExpectedStats ¶
type ExpectedStats struct {
// contains filtered or unexported fields
}
func (*ExpectedStats) String ¶
func (e *ExpectedStats) String() string
func (*ExpectedStats) WillReturnStats ¶
func (e *ExpectedStats) WillReturnStats(stats clikhouseDriver.Stats) *ExpectedStats
WillReturnStats allows to set an error for the expected *Conn.Stats action.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
func NewRows ¶
func NewRows(columns []ColumnType, values [][]any) *Rows
func (*Rows) ColumnTypes ¶
func (r *Rows) ColumnTypes() []driver.ColumnType