clickhouse-testing-macros

Crates.ioclickhouse-testing-macros
lib.rsclickhouse-testing-macros
version0.1.2
created_at2025-09-02 22:30:37.98774+00
updated_at2025-10-16 13:49:25.611962+00
descriptionA crate that simplifies writing integration tests for ClickHouse, inspired by sqlx.
homepage
repositoryhttps://github.com/rdcm/clickhouse-testing
max_upload_size
id1821738
size5,999
(rdcm)

documentation

README

About

A crate that simplifies writing integration tests for ClickHouse, inspired by sqlx.

Getting Started

Add the following environment variables to a .env file:

MIGRATIONS_DIR=".migrations"
CLICKHOUSE_URL="http://localhost:8123"
CLICKHOUSE_DB="db"
CLICKHOUSE_USER="user"
CLICKHOUSE_PASSWORD="password"

Write a test:

#[clickhouse_testing::test]
async fn test1(client: clickhouse_testing::Client) {
    let version = client
        .query("SELECT version()")
        .fetch_one::<String>()
        .await
        .unwrap();

    assert_eq!(version, "25.5.2.47");
}

Behavior

  • Each test creates a unique database in the ClickHouse instance. Unique key: {module_name} + {test_name} + {run_id}.
  • Before each test, the new schema is applied to "test_db".
  • After successful test execution, "test_db" is deleted. If any error occurs, "test_db" is preserved for investigation.

Enjoy!

Commit count: 9

cargo fmt