Skip to content

Commit 36888ca

Browse files
committed
Add error state tests for --custom-schemes flag
1 parent 27d92f8 commit 36888ca

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

src/operations/list.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ pub fn list(data_path: &Path, is_custom: bool) -> Result<()> {
2525
}
2626
(false, false) => {
2727
return Err(anyhow!(
28-
"Scheme repo path does not exist: {}\nRun `{} install` and try again",
29-
schemes_dir_path.display(),
28+
"Schemes are missing, run install and then try again: `{} install`",
3029
REPO_NAME
3130
))
3231
}

tests/cli_info_subcommand_tests.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,35 @@ fn test_cli_info_subcommand_without_setup() -> Result<()> {
9797
Ok(())
9898
}
9999

100+
#[test]
101+
fn test_cli_info_subcommand_without_setup_with_custom_schemes_flag() -> Result<()> {
102+
// -------
103+
// Arrange
104+
// -------
105+
let test_name = "test_info_list_subcommand_without_setup_with_custom_schemes_flag";
106+
let (_, _, command_vec, cleanup) = setup(test_name, "list --custom-schemes")?;
107+
let expected_output = format!(
108+
"You don't have any local custom schemes at: data_path_{}/custom-schemes",
109+
test_name
110+
);
111+
112+
// ---
113+
// Act
114+
// ---
115+
let (_, stderr) = utils::run_command(command_vec).unwrap();
116+
117+
// ------
118+
// Assert
119+
// ------
120+
assert!(
121+
stderr.contains(&expected_output),
122+
"stdout does not contain the expected output"
123+
);
124+
125+
cleanup()?;
126+
Ok(())
127+
}
128+
100129
#[test]
101130
fn test_cli_info_subcommand_with_setup_invalid_scheme_name() -> Result<()> {
102131
// -------

tests/cli_list_subcommand_tests.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,35 @@ fn test_cli_list_subcommand_without_setup() -> Result<()> {
3434
Ok(())
3535
}
3636

37+
#[test]
38+
fn test_cli_list_subcommand_without_setup_with_custom_schemes_flag() -> Result<()> {
39+
// -------
40+
// Arrange
41+
// -------
42+
let test_name = "test_cli_list_subcommand_without_setup_with_custom_schemes_flag";
43+
let (_, _, command_vec, cleanup) = setup(test_name, "list --custom-schemes")?;
44+
let expected_output = format!(
45+
"You don't have any local custom schemes at: data_path_{}/custom-schemes",
46+
test_name
47+
);
48+
49+
// ---
50+
// Act
51+
// ---
52+
let (_, stderr) = utils::run_command(command_vec).unwrap();
53+
54+
// ------
55+
// Assert
56+
// ------
57+
assert!(
58+
stderr.contains(&expected_output),
59+
"stdout does not contain the expected output"
60+
);
61+
62+
cleanup()?;
63+
Ok(())
64+
}
65+
3766
#[test]
3867
fn test_cli_list_subcommand_with_setup() -> Result<()> {
3968
// -------

0 commit comments

Comments
 (0)