From 115b2084ca2c684b51d307f720d9daad989f9430 Mon Sep 17 00:00:00 2001 From: Michael Spracklen Date: Mon, 24 Jun 2024 19:51:32 -0500 Subject: [PATCH] getting started integration tests initial concept --- .../sqlite/getting_started_step_2/Cargo.toml | 3 +++ .../getting_started_step_2/tests/step_2.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 examples/sqlite/getting_started_step_2/tests/step_2.rs diff --git a/examples/sqlite/getting_started_step_2/Cargo.toml b/examples/sqlite/getting_started_step_2/Cargo.toml index 9d645210109a..1bf034062ff8 100644 --- a/examples/sqlite/getting_started_step_2/Cargo.toml +++ b/examples/sqlite/getting_started_step_2/Cargo.toml @@ -10,6 +10,9 @@ diesel = { version = "2.1.0", path = "../../../diesel", features = ["sqlite", "r dotenvy = "0.15" libsqlite3-sys = { version = "0.28.0", features = ["bundled"] } +[dev-dependencies] +assert_cmd = "2.0.14" + [[bin]] name = "show_posts" doc = false diff --git a/examples/sqlite/getting_started_step_2/tests/step_2.rs b/examples/sqlite/getting_started_step_2/tests/step_2.rs new file mode 100644 index 000000000000..06c14f237254 --- /dev/null +++ b/examples/sqlite/getting_started_step_2/tests/step_2.rs @@ -0,0 +1,16 @@ +use assert_cmd::Command; + +#[test] +fn write_post() { + let _ = Command::cargo_bin("write_post") + .unwrap() + .write_stdin("Test Title\ntest text\n1 2 3") + .assert() + .append_context("write_post", "") + .stdout("What would you like your title to be?\n\nOk! Let's write Test Title (Press CTRL+D when finished)\n\n\nSaved draft Test Title with id 1\n"); + let _ = Command::cargo_bin("show_posts") + .unwrap() + .assert() + .append_context("show_posts", "") + .stdout("Displaying 0 posts\n"); +}