sqlness/lib.rs
1// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
2
3//! **SQL** integration test har**NESS**
4//!
5//! ## Usage
6//!
7//! The entrypoint of this crate is [Runner] struct. It runs your test cases and
8//! compare the result. There are three things you need to do to complete an
9//! integration test:
10//! - Prepare the test case (of course!)
11//! - Implement [`EnvController`] and [`Database`]. They provide methods to start
12//! the server, submit the query and clean up etc.
13//! - Format the result. Implement [`Display`] for your query result to make them
14//! comparable.
15//!
16//! And then all you need is to run the runner!
17//!
18//! ```rust, ignore, no_run
19//! async fn run_integration_test() {
20//! let runner = Runner::new(root_path, env).await;
21//! runner.run().await;
22//! }
23//! ```
24//!
25//! [`Display`]: std::fmt::Display
26//!
27//! ## Directory organization
28//!
29//! An example directory tree is:
30//!
31//! ```plaintext
32//! sqlness
33//! ├── local
34//! │ ├── config.toml
35//! │ ├── dml
36//! │ │ └── basic.sql
37//! │ │ └── basic.result
38//! │ ├── ddl
39//! │ └── system
40//! └── remote
41//! ├── config.toml
42//! ├── dml
43//! ├── ddl
44//! └── system
45//! ```
46//!
47//! Here the root dir is `sqlness`, it contains two sub-directories for different
48//! "environments": `local` and `remote`. Each environment has an env-specific
49//! configuration `config.toml`. All the test cases are placed under corresponding
50//! environment directory.
51//!
52//! Note that only the first layer of sub-directory is special (for distinguash
53//! different environments). All deeper layers are treated as the same. E.g.,
54//! both `sqlness/local/dml/basic.sql` and `sqlness/local/dml/another-dir/basic.sql`
55//! will be run under the `local` env in the same pass.
56
57mod case;
58mod config;
59mod database;
60pub mod database_impl;
61mod environment;
62mod error;
63pub mod interceptor;
64mod runner;
65
66pub use case::QueryContext;
67pub use config::{Config, ConfigBuilder, DatabaseConfig, DatabaseConfigBuilder};
68pub use database::Database;
69pub use environment::EnvController;
70pub use error::SqlnessError;
71pub use runner::Runner;