Skip to content

Commit

Permalink
add dev dependencies for testing wal_checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sonhmai authored and sonhmai committed Jan 16, 2025
1 parent 807e0f4 commit 465f14f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 55 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ miette = { version = "7.4.0", features = ["fancy"] }
[features]
io_uring = ["limbo_core/io_uring"]

[dev-dependencies]
# not testing the cli on windows as rexpect does not support it.
[target.'cfg(not(windows))'.dev-dependencies]
assert_cmd = "^2"
predicates = "^3"

# rexpect does not support windows https://github.com/rust-cli/rexpect/issues/11
#[target.'cfg(not(windows))'.dev-dependencies]
rexpect = "0.6.0"
67 changes: 36 additions & 31 deletions cli/tests/test_journal.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
use assert_cmd::cargo::cargo_bin;
use rexpect::error::*;
use rexpect::session::spawn_command;
use std::process;
/// rexpect does not work on Windows.
/// https://github.com/rust-cli/rexpect/issues/11
#[cfg(not(target_os = "windows"))]
mod tests {
use assert_cmd::cargo::cargo_bin;
use rexpect::error::*;
use rexpect::session::spawn_command;
use std::process;

#[test]
fn test_pragma_journal_mode_wal() -> Result<(), Error> {
let mut child = spawn_command(run_cli(), Some(1000))?;
child.exp_regex("limbo>")?; // skip everything until limbo cursor appear
child.exp_regex(".?")?;
child.send_line("pragma journal_mode;")?;
child.exp_string("wal")?;
child.send_line(".quit")?;
child.exp_eof()?;
Ok(())
}
#[test]
fn test_pragma_journal_mode_wal() -> Result<(), Error> {
let mut child = spawn_command(run_cli(), Some(1000))?;
child.exp_regex("limbo>")?; // skip everything until limbo cursor appear
child.exp_regex(".?")?;
child.send_line("pragma journal_mode;")?;
child.exp_string("wal")?;
child.send_line(".quit")?;
child.exp_eof()?;
Ok(())
}

#[ignore = "wal checkpoint not yet implemented"]
#[test]
fn test_pragma_wal_checkpoint() -> Result<(), Error> {
let mut child = spawn_command(run_cli(), Some(1000))?;
child.exp_regex("limbo>")?; // skip everything until limbo cursor appear
child.exp_regex(".?")?;
child.send_line("pragma wal_checkpoint;")?;
child.exp_string("0|0|0")?;
child.send_line(".quit")?;
child.exp_eof()?;
Ok(())
}
#[ignore = "wal checkpoint not yet implemented"]
#[test]
fn test_pragma_wal_checkpoint() -> Result<(), Error> {
let mut child = spawn_command(run_cli(), Some(1000))?;
child.exp_regex("limbo>")?; // skip everything until limbo cursor appear
child.exp_regex(".?")?;
child.send_line("pragma wal_checkpoint;")?;
child.exp_string("0|0|0")?;
child.send_line(".quit")?;
child.exp_eof()?;
Ok(())
}

fn run_cli() -> process::Command {
let bin_path = cargo_bin("limbo");
let mut cmd = process::Command::new(bin_path);
cmd
fn run_cli() -> process::Command {
let bin_path = cargo_bin("limbo");
let mut cmd = process::Command::new(bin_path);
cmd
}
}

0 comments on commit 465f14f

Please sign in to comment.