diff options
-rw-r--r-- | tests/cli.rs | 20 |
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(()) +} |