58 releases (25 breaking)

new 0.26.2 Jan 10, 2025
0.25.0 Dec 26, 2024
0.23.0 Nov 17, 2024
0.21.0 Jul 1, 2024
0.1.0 Dec 10, 2021

#157 in Database interfaces

Download history 9708/week @ 2024-09-20 11165/week @ 2024-09-27 10671/week @ 2024-10-04 13048/week @ 2024-10-11 13851/week @ 2024-10-18 12645/week @ 2024-10-25 10941/week @ 2024-11-01 11394/week @ 2024-11-08 11269/week @ 2024-11-15 10648/week @ 2024-11-22 8195/week @ 2024-11-29 10388/week @ 2024-12-06 12079/week @ 2024-12-13 9348/week @ 2024-12-20 7562/week @ 2024-12-27 98047/week @ 2025-01-03

129,051 downloads per month
Used in 6 crates

MIT/Apache

130KB
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

~9–19MB
~284K SLoC