52 releases (22 breaking)

0.23.0 Nov 17, 2024
0.21.0 Jul 1, 2024
0.19.1 Jan 4, 2024
0.19.0 Nov 14, 2023
0.1.0 Dec 10, 2021

#113 in Database interfaces

Download history 12745/week @ 2024-08-19 12251/week @ 2024-08-26 11967/week @ 2024-09-02 10066/week @ 2024-09-09 8975/week @ 2024-09-16 11134/week @ 2024-09-23 9992/week @ 2024-09-30 12345/week @ 2024-10-07 12566/week @ 2024-10-14 13433/week @ 2024-10-21 12367/week @ 2024-10-28 10495/week @ 2024-11-04 11506/week @ 2024-11-11 11909/week @ 2024-11-18 9080/week @ 2024-11-25 8889/week @ 2024-12-02

42,095 downloads per month
Used in 6 crates

MIT/Apache

120KB
3K SLoC

Sqllogictest

Sqllogictest is a testing framework to verify the correctness of an SQL database. See GitHub Homepage for more information.

This crate implements a sqllogictest parser and runner library in Rust.


lib.rs:

Sqllogictest parser and runner.

This crate supports multiple extensions beyond the original sqllogictest format. See the README for more information.

Usage

For how to use the CLI tool backed by this library, see the README.

For using the crate as a lib, and implement your custom driver, see below.

Implement [DB] trait for your database structure:

struct MyDatabase {
    // fields
}

#[derive(thiserror::Error, Debug, PartialEq, Eq, Clone)]
enum MyError {
    // variants
}

impl sqllogictest::DB for MyDatabase {
    type Error = MyError;
    // Or define your own column type
    type ColumnType = sqllogictest::DefaultColumnType;
    fn run(
        &mut self,
        sql: &str,
    ) -> Result<sqllogictest::DBOutput<Self::ColumnType>, Self::Error> {
        // TODO
        Ok(sqllogictest::DBOutput::StatementComplete(0))
    }
}

// Then create a `Runner` on your database instance, and run the tests:
let mut tester = sqllogictest::Runner::new(|| async {
    let db = MyDatabase {
        // fields
    };
    Ok(db)
});
let _res = tester.run_file("../tests/slt/basic.slt");

// You can also parse the script and execute the records separately:
let records = sqllogictest::parse_file("../tests/slt/basic.slt").unwrap();
for record in records {
    let _res = tester.run(record);
}

Dependencies

~8–19MB
~276K SLoC