Skip to content

Commit

Permalink
fix doctest
Browse files Browse the repository at this point in the history
Signed-off-by: xxchan <[email protected]>
  • Loading branch information
xxchan committed Jun 30, 2024
1 parent c9f7dc9 commit 1d53c65
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ jobs:
with:
command: test
args: --no-fail-fast
- name: Doctest
uses: actions-rs/cargo@v1
with:
command: test
args: --doc

semver:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SELECT * FROM foo;

The syntax:
- Do not check the error message: `[statement|query] error`
- Single line error message (regexp match): `[statement|query] error <regex>` and ` error <regex>`
- Single line error message (regexp match): `[statement|query] error <regex>`
- Multiline error message (exact match): Use `----`.

```text
Expand Down
47 changes: 27 additions & 20 deletions sqllogictest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,39 @@
//!
//! Implement [`DB`] trait for your database structure:
//!
//! ```ignore
//! struct Database {...}
//! ```
//! struct MyDatabase {
//! // fields
//! }
//!
//! impl sqllogictest::DB for Database {
//! type Error = ...;
//! type ColumnType = ...;
//! #[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:
//!
//! ```ignore
//! let db = Database {...};
//! let mut tester = sqllogictest::Runner::new(db);
//! tester.run_file("script.slt").unwrap();
//! ```
//!
//! You can also parse the script and execute the records separately:
//!
//! ```ignore
//! let records = sqllogictest::parse_file("script.slt").unwrap();
//! // 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 {
//! tester.run(record).unwrap();
//! let _res = tester.run(record);
//! }
//! ```
Expand Down

0 comments on commit 1d53c65

Please sign in to comment.