From 47be40afaeaa4176c237a1863311b54f55b74d1d Mon Sep 17 00:00:00 2001 From: ndd7xv Date: Fri, 25 Feb 2022 21:17:43 -0500 Subject: [PATCH] install: add tests for error handling --- tests/by-util/test_install.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 23bebf224..3d78331f9 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -1100,3 +1100,27 @@ fn test_install_backup_off() { assert!(at.file_exists(file_b)); assert!(!at.file_exists(&format!("{}~", file_b))); } + +#[test] +fn test_install_missing_arguments() { + let scene = TestScenario::new(util_name!()); + + scene + .ucmd() + .fails() + .stderr_contains("install: missing file operand"); +} + +#[test] +fn test_install_missing_destination() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + let file_1 = "source_file1"; + + at.touch(file_1); + scene.ucmd().arg(file_1).fails().stderr_contains(format!( + "install: missing destination file operand after '{}'", + file_1 + )); +}