summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-12 10:52:52 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-12 10:52:52 +0200
commit6268956e826b477a2f6fecde7d1ab701fffb1f58 (patch)
tree465336dce564ad7afec196affcfd71b9cf0bd71b /tests
parent201639c812c0afa9b19e576055d25977192606ac (diff)
Test for batch command
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 01e8f2b..fcd1437 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -19,6 +19,18 @@ fn spawn_interactive_process() -> Result<TestContext> {
Ok(TestContext { p, workdir })
}
+fn run_batch_command(batch_command: &str) -> Result<TestContext> {
+ let workdir = tempfile::tempdir()?;
+
+ let path = cargo_bin(env!("CARGO_PKG_NAME"));
+ let mut command = std::process::Command::new(&path);
+ command.current_dir(&workdir);
+ command.args(["-c", batch_command]);
+ let p = spawn_command(command, Some(3000))?;
+
+ Ok(TestContext { p, workdir })
+}
+
fn expect_prompt(p: &mut PtySession) -> Result<()> {
p.exp_string("> ")?;
Ok(())
@@ -90,3 +102,11 @@ fn can_init_a_new_git_repo() -> Result<()> {
.stdout("");
Ok(())
}
+
+#[test]
+fn runs_a_single_command_and_exit_with_cli_flag() -> Result<()> {
+ let mut c = run_batch_command("git-init another-new-repo")?;
+ c.p.exp_string("Successfully created my-new-repo.git")?;
+ c.p.exp_eof()?;
+ Ok(())
+}