### Install clickhouse-go-mock Source: https://github.com/srikanthccv/clickhouse-go-mock/blob/main/README.md This command installs the clickhouse-go-mock library using the Go build tools. It fetches the latest version of the library from its repository. ```go go get github.com/srikanthccv/ClickHouse-go-mock ``` -------------------------------- ### Quick Start: Mocking ClickHouse Queries in Go Source: https://github.com/srikanthccv/clickhouse-go-mock/blob/main/README.md Demonstrates how to use clickhouse-go-mock to mock a ClickHouse database connection and execute a query. It sets up expectations for a specific SQL query with arguments and verifies that the mock received the expected calls. ```go package main import ( "context" "log" "github.com/ClickHouse/clickhouse-go/v2" cmock "github.com/srikanthccv/ClickHouse-go-mock" ) type Video struct { Name string `db:"name"` Title string `db:"title"` Content string `db:"content"` } func fetchVideos(conn clickhouse.Conn) (*Video, error) { var video Video if _, err := conn.Query(context.TODO(), "SELECT name, title, content FROM videos WHERE name LIKE ?", "%Cocomelon%"); err != nil { return nil, err } return &video, nil } func main() { mock, err := cmock.NewClickHouseNative(nil) if err != nil { log.Fatalf("an error '%s' was not expected when opening a stub database connection", err) } mock.ExpectQuery("SELECT name, title, content FROM videos WHERE name LIKE ?").WithArgs("%Cocomelon%") _, err = fetchVideos(mock) if err != nil { log.Fatalf("an error '%s' was not expected when querying a statement", err) } if err := mock.ExpectationsWereMet(); err != nil { log.Fatalf("there were unfulfilled expectations: %s", err) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.