refactor: move config list

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-01 17:01:00 +02:00
parent e51454088e
commit ae9073bf0b
8 changed files with 93 additions and 58 deletions

View File

@@ -108,8 +108,8 @@ impl From<&BufferUi> for DynUi {
pub fn assert_output(ui: &BufferUi, expected_stdout: &str, expected_stderr: &str) {
let (stdout, stderr) = ui.get_output();
assert_eq!(expected_stdout, &stdout);
assert_eq!(expected_stderr, &stderr);
pretty_assertions::assert_eq!(expected_stdout, &stdout);
pretty_assertions::assert_eq!(expected_stderr, &stderr);
}
pub fn get_test_data_path(item: &str) -> PathBuf {

View File

@@ -16,6 +16,14 @@ fn get_base_args<'a>() -> Vec<&'a str> {
]
}
const EXPECTED_OUTPUT: &'static str = r#"cuddle-config
PleaseConfig
owner: kjuulh
repository: cuddle-please
branch: main
api_url: https://some-example.gitea-instance
"#;
#[test]
#[traced_test]
fn test_config_from_current_dir() {
@@ -27,7 +35,7 @@ fn test_config_from_current_dir() {
.execute(Some(&current_dir))
.unwrap();
assert_output(ui, "cuddle-config\n", "");
assert_output(ui, EXPECTED_OUTPUT, "");
}
#[test]
@@ -43,7 +51,7 @@ fn test_config_from_source_dir() {
.execute(None)
.unwrap();
assert_output(ui, "cuddle-config\n", "");
assert_output(ui, EXPECTED_OUTPUT, "");
}
#[test]
@@ -57,14 +65,13 @@ project:
repository: cuddle-please
branch: main
settings:
api_url: https://some-example.gitea-instance
"#;
api_url: https://some-example.gitea-instance"#;
args.push("--config-stdin");
PleaseCommand::new_from_args_with_stdin(Some(ui), args, || Ok(config.into()))
.execute(None)
.unwrap();
assert_output(ui, "cuddle-config\n", "");
assert_output(ui, EXPECTED_OUTPUT, "");
}
#[test]