Skip to main content

Crate sqlness

Crate sqlness 

Source
Expand description

SQL integration test harNESS

§Usage

The entrypoint of this crate is Runner struct. It runs your test cases and compare the result. There are three things you need to do to complete an integration test:

  • Prepare the test case (of course!)
  • Implement EnvController and Database. They provide methods to start the server, submit the query and clean up etc.
  • Format the result. Implement Display for your query result to make them comparable.

And then all you need is to run the runner!

ⓘ
async fn run_integration_test() {
    let runner = Runner::new(root_path, env).await;
    runner.run().await;
}

§Directory organization

An example directory tree is:

sqlness
├── local
│   ├── config.toml
│   ├── dml
│   │   └── basic.sql
│   │   └── basic.result
│   ├── ddl
│   └── system
└── remote
    ├── config.toml
    ├── dml
    ├── ddl
    └── system

Here the root dir is sqlness, it contains two sub-directories for different “environments”: local and remote. Each environment has an env-specific configuration config.toml. All the test cases are placed under corresponding environment directory.

Note that only the first layer of sub-directory is special (for distinguash different environments). All deeper layers are treated as the same. E.g., both sqlness/local/dml/basic.sql and sqlness/local/dml/another-dir/basic.sql will be run under the local env in the same pass.

Modules§

database_impl
interceptor
Query interceptor implementations.

Structs§

Config
Configurations of Runner.
ConfigBuilder
Builder for Config.
DatabaseConfig
Config for DatabaseBuilder
DatabaseConfigBuilder
Builder for DatabaseConfig.
QueryContext
A String-to-String map used as query context.
Runner
The entrypoint of this crate.

Enums§

SqlnessError

Traits§

Database
Query executor.
EnvController
Controller of test environments.
impl<W> Write for Arc<W>
where\n W: Write + IoHandle + ?Sized,\n &'a W: for<'a> Write,
","Arc, A>":"

Notable traits for Arc<R>

impl<R> Read for Arc<R>
where\n R: Read + IoHandle + ?Sized,\n &'a R: for<'a> Read,
impl<W> Write for Arc<W>
where\n W: Write + IoHandle + ?Sized,\n &'a W: for<'a> Write,
","Arc>":"

Notable traits for Arc<R>

impl<R> Read for Arc<R>
where\n R: Read + IoHandle + ?Sized,\n &'a R: for<'a> Read,
impl<W> Write for Arc<W>
where\n W: Write + IoHandle + ?Sized,\n &'a W: for<'a> Write,
","Arc":"

Notable traits for Arc<R>

impl<R> Read for Arc<R>
where\n R: Read + IoHandle + ?Sized,\n &'a R: for<'a> Read,
impl<W> Write for Arc<W>
where\n W: Write + IoHandle + ?Sized,\n &'a W: for<'a> Write,
","Arc":"

Notable traits for Arc<R>

impl<R> Read for Arc<R>
where\n R: Read + IoHandle + ?Sized,\n &'a R: for<'a> Read,
impl<W> Write for Arc<W>
where\n W: Write + IoHandle + ?Sized,\n &'a W: for<'a> Write,
","Arc":"

Notable traits for Arc<R>

impl<R> Read for Arc<R>
where\n R: Read + IoHandle + ?Sized,\n &'a R: for<'a> Read,
impl<W> Write for Arc<W>
where\n W: Write + IoHandle + ?Sized,\n &'a W: for<'a> Write,
","ArrayChunks":"

Notable traits for ArrayChunks<I, N>

impl<I, const N: usize> Iterator for ArrayChunks<I, N>
where\n I: Iterator,
type Item = [<I as Iterator>::Item; N];
","Bytes":"

Notable traits for Bytes<R>

impl<R> Iterator for Bytes<R>
where\n R: Read,
type Item = Result<u8, Error>;
","Chain::IntoIter>":"

Notable traits for Chain<A, B>

impl<A, B> Iterator for Chain<A, B>
where\n A: Iterator,\n B: Iterator<Item = <A as Iterator>::Item>,
type Item = <A as Iterator>::Item;
","Chain":"

Notable traits for Chain<T, U>

impl<T, U> Read for Chain<T, U>
where\n T: Read,\n U: Read,
","Cloned":"

Notable traits for Cloned<I>

impl<'a, I, T> Iterator for Cloned<I>
where\n T: 'a + Clone,\n I: Iterator<Item = &'a T>,
type Item = T;
","Copied":"

Notable traits for Copied<I>

impl<'a, I, T> Iterator for Copied<I>
where\n T: 'a + Copy,\n I: Iterator<Item = &'a T>,
type Item = T;
","Cycle":"

Notable traits for Cycle<I>

impl<I> Iterator for Cycle<I>
where\n I: Clone + Iterator,
type Item = <I as Iterator>::Item;
","Enumerate":"

Notable traits for Enumerate<I>

impl<I> Iterator for Enumerate<I>
where\n I: Iterator,
type Item = (usize, <I as Iterator>::Item);
","Filter":"

Notable traits for Filter<I, P>

impl<I, P> Iterator for Filter<I, P>
where\n I: Iterator,\n P: FnMut(&<I as Iterator>::Item) -> bool,
type Item = <I as Iterator>::Item;
","FilterMap":"

Notable traits for FilterMap<I, F>

impl<B, I, F> Iterator for FilterMap<I, F>
where\n I: Iterator,\n F: FnMut(<I as Iterator>::Item) -> Option<B>,
type Item = B;
","FlatMap":"

Notable traits for FlatMap<I, U, F>

impl<I, U, F> Iterator for FlatMap<I, U, F>
where\n I: Iterator,\n U: IntoIterator,\n F: FnMut(<I as Iterator>::Item) -> U,
type Item = <U as IntoIterator>::Item;
","Flatten":"

Notable traits for Flatten<I>

impl<I, U> Iterator for Flatten<I>
where\n I: Iterator,\n <I as Iterator>::Item: IntoIterator<IntoIter = U, Item = <U as Iterator>::Item>,\n U: Iterator,
type Item = <U as Iterator>::Item;
","Fuse":"

Notable traits for Fuse<I>

impl<I> Iterator for Fuse<I>
where\n I: Iterator,
type Item = <I as Iterator>::Item;
","Inspect":"

Notable traits for Inspect<I, F>

impl<I, F> Iterator for Inspect<I, F>
where\n I: Iterator,\n F: FnMut(&<I as Iterator>::Item),
type Item = <I as Iterator>::Item;
","Intersperse":"

Notable traits for Intersperse<I>

impl<I> Iterator for Intersperse<I>
where\n I: Iterator,\n <I as Iterator>::Item: Clone,
type Item = <I as Iterator>::Item;
","IntersperseWith":"

Notable traits for IntersperseWith<I, G>

impl<I, G> Iterator for IntersperseWith<I, G>
where\n I: Iterator,\n G: FnMut() -> <I as Iterator>::Item,
type Item = <I as Iterator>::Item;
","Lines":"

Notable traits for Lines<B>

impl<B> Iterator for Lines<B>
where\n B: BufRead,
type Item = Result<String, Error>;
","Map":"

Notable traits for Map<I, F>

impl<B, I, F> Iterator for Map<I, F>
where\n I: Iterator,\n F: FnMut(<I as Iterator>::Item) -> B,
type Item = B;
","MapWhile":"

Notable traits for MapWhile<I, P>

impl<B, I, P> Iterator for MapWhile<I, P>
where\n I: Iterator,\n P: FnMut(<I as Iterator>::Item) -> Option<B>,
type Item = B;
","MapWindows":"

Notable traits for MapWindows<I, F, N>

impl<I, F, R, const N: usize> Iterator for MapWindows<I, F, N>
where\n I: Iterator,\n F: FnMut(&[<I as Iterator>::Item; N]) -> R,
type Item = R;
","Peekable":"

Notable traits for Peekable<I>

impl<I> Iterator for Peekable<I>
where\n I: Iterator,
type Item = <I as Iterator>::Item;
","Rev":"

Notable traits for Rev<I>

impl<I> Iterator for Rev<I>
type Item = <I as Iterator>::Item;
","Scan":"

Notable traits for Scan<I, St, F>

impl<B, I, St, F> Iterator for Scan<I, St, F>
where\n I: Iterator,\n F: FnMut(&mut St, <I as Iterator>::Item) -> Option<B>,
type Item = B;
","Skip":"

Notable traits for Skip<I>

impl<I> Iterator for Skip<I>
where\n I: Iterator,
type Item = <I as Iterator>::Item;
","SkipWhile":"

Notable traits for SkipWhile<I, P>

impl<I, P> Iterator for SkipWhile<I, P>
where\n I: Iterator,\n P: FnMut(&<I as Iterator>::Item) -> bool,
type Item = <I as Iterator>::Item;
","Split":"

Notable traits for Split<B>

impl<B> Iterator for Split<B>
where\n B: BufRead,
type Item = Result<Vec<u8>, Error>;
","StepBy":"

Notable traits for StepBy<I>

impl<I> Iterator for StepBy<I>
where\n I: Iterator,
type Item = <I as Iterator>::Item;
","Take":"

Notable traits for Take<T>

impl<T> Read for Take<T>
where\n T: Read,
","TakeWhile":"

Notable traits for TakeWhile<I, P>

impl<I, P> Iterator for TakeWhile<I, P>
where\n I: Iterator,\n P: FnMut(&<I as Iterator>::Item) -> bool,
type Item = <I as Iterator>::Item;
","Zip::IntoIter>":"

Notable traits for Zip<A, B>

impl<A, B> Iterator for Zip<A, B>
where\n A: Iterator,\n B: Iterator,
type Item = (<A as Iterator>::Item, <B as Iterator>::Item);
"}