summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-17 11:10:53 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-17 11:11:36 +0200
commitf5a00e9090b9d81936137c3fc676cfd0ad25430c (patch)
tree5384a422af6ec34685b31308caf2fd70f1d6114e /tests
parentb541b141e66d5cf0ba4b190eda6422126951af6e (diff)
Use shlex to split shell arguments
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs36
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 6ace151..e6a59b3 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -90,7 +90,7 @@ fn reports_error_with_nonsense_input() -> Result<()> {
fn can_init_a_new_git_repo() -> Result<()> {
let mut c = spawn_interactive_process()?;
c.p.send_line("git-init my-new-repo")?;
- c.p.exp_string("Successfully created my-new-repo.git")?;
+ c.p.exp_string("Successfully created \"my-new-repo.git\"")?;
expect_prompt(&mut c.p)?;
Command::new("git")
@@ -106,7 +106,39 @@ fn can_init_a_new_git_repo() -> Result<()> {
#[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 another-new-repo.git")?;
+ c.p.exp_string("Successfully created \"another-new-repo.git\"")?;
c.p.exp_eof()?;
Ok(())
}
+
+#[test]
+fn allows_quotes_arguments() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ c.p.send_line("\"git-init\" 'another-new-repo'")?;
+ c.p.exp_string("Successfully created \"another-new-repo.git\"")?;
+ Ok(())
+}
+
+#[test]
+fn errors_with_an_open_double_quote() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ c.p.send_line("\"git-init 'another-new-repo'")?;
+ c.p.exp_string("Incomplete input")?;
+ Ok(())
+}
+
+#[test]
+fn errors_with_an_open_single_quote() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ c.p.send_line("'git-init 'another-new-repo'")?;
+ c.p.exp_string("Incomplete input")?;
+ Ok(())
+}
+
+#[test]
+fn allows_single_quotes_and_spaces_inside_double_quotes() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ c.p.send_line("git-init \"shukkie's new repo\"")?;
+ c.p.exp_string("Successfully created \"shukkie's new repo.git\"")?;
+ Ok(())
+}