Skip to content

Commit

Permalink
feat: Add ability to create mock clickhouse with custom query matcher (
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-k-singh committed Mar 1, 2024
1 parent 9bc063c commit bb800cd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ func init() {

// NewClickHouseNative creates clickhousemock database mock to manage expectations.
func NewClickHouseNative(options *clickhouse.Options) (*clickhousemock, error) {
return NewClickHouseWithQueryMatcher(options, sqlmock.QueryMatcherEqual)
}

func NewClickHouseWithQueryMatcher(
options *clickhouse.Options,
queryMatcher sqlmock.QueryMatcher,
) (*clickhousemock, error) {
clickHousePool.Lock()
dsn := fmt.Sprintf("clickhousemock_db_%d", clickHousePool.counter)
clickHousePool.counter++

cmock := &clickhousemock{dsn: dsn, drv: clickHousePool, ordered: true, queryMatcher: sqlmock.QueryMatcherEqual}
cmock := &clickhousemock{dsn: dsn, drv: clickHousePool, ordered: true, queryMatcher: queryMatcher}
clickHousePool.conns[dsn] = cmock
clickHousePool.Unlock()

Expand Down

0 comments on commit bb800cd

Please sign in to comment.