PandeyandGitHub 7ab8f8e001 feat: rename module to SigNoz and support clickhouse-go v2.44.0 (#4)
## Why

`clickhouse-go/v2` **v2.44.0** added a new method `HasData() bool` to
the `driver.Rows` interface. SigNoz needs to upgrade to v2.44.0 (it
fixes a connection-pool slot leak — `acquire conn timeout` — introduced
in v2.43.0 via PRs #1759/#1795), but this mock's `*Rows` did not
implement `HasData()`, so it no longer satisfies `driver.Rows` and
breaks the build.

This ports the mock into a SigNoz-owned module and adds the missing
method.

## What

- Rename module path `github.com/srikanthccv/ClickHouse-go-mock` →
`github.com/SigNoz/clickhouse-go-mock` (incl. example imports).
- Bump `github.com/ClickHouse/clickhouse-go/v2` `v2.43.0` → `v2.44.0`.
- Implement `Rows.HasData()` to satisfy the v2.44.0 `driver.Rows`
interface (mirrors `Next()` semantics).
- Fix `non-constant format string in call to fmt.Errorf` vet errors
flagged by the current Go toolchain.

## Verification

- `go build ./...` ✅
- `go vet ./...` ✅
- `go test ./...` ✅
2026-05-29 23:51:54 +05:30
2025-06-21 09:18:57 +05:30
2023-09-23 16:04:04 +05:30
2025-03-17 21:44:09 +05:30
2023-09-30 12:23:21 +05:30
2023-09-30 12:23:21 +05:30
2022-11-05 19:56:26 +05:30
2023-09-30 12:18:51 +05:30
2023-09-30 12:21:39 +05:30
2023-09-30 12:21:39 +05:30
2023-09-30 12:21:39 +05:30

ClickHouse-go-mock

A mock library implementing support for clickhouse-go/v2/lib/driver

Install

go get github.com/srikanthccv/ClickHouse-go-mock

Quick Start


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)
	}
}

Documentation

Please see the package documentation at godoc.org.

And tests are the best documentation, see clickconnmock_test.go.

License

The Apache License, Version 2.0 - see LICENSE for more details.

Credits

This library is built on top of clickhouse-go and sqlmock

S
Description
SUPERSEDED by hanzo-ds/mock — the datastore family lives in the hanzo-ds org (go, mock, native, driver, connect, pool, sqlbuilder, sqlparser, js, rs, cpp). Kept only as a pre-debrand snapshot from cloud's embedded git.
Readme Apache-2.0
138 KiB
Languages
Go 100%