Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 00dc277

Browse files
committed
Added test for config/package hack.
1 parent c5b6fd5 commit 00dc277

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/provider/states/pod/creating_config.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,10 @@ impl State<PodState> for CreatingConfig {
411411
#[cfg(test)]
412412
mod tests {
413413
use super::*;
414+
use rstest::rstest;
414415
use std::collections::BTreeMap;
415416
use std::path::PathBuf;
417+
use std::str::FromStr;
416418

417419
#[test]
418420
fn test_render_template() {
@@ -445,4 +447,25 @@ mod tests {
445447
let legal_path_string = CreatingConfig::pathbuf_to_string("testfield", legal_path).unwrap();
446448
assert_eq!(input_path_string, legal_path_string);
447449
}
450+
451+
#[rstest]
452+
#[case("{{packageroot}}/test", "/opt/stackable/packages/test")]
453+
#[case("/test", "/test")]
454+
#[case("test", "/etc/stackable/config/test")]
455+
fn test_create_config_path(#[case] input: &str, #[case] expected_output: &str) {
456+
let mut template_data: BTreeMap<String, String> = BTreeMap::new();
457+
458+
template_data.insert(
459+
"packageroot".to_string(),
460+
"/opt/stackable/packages".to_string(),
461+
);
462+
463+
let config_dir = PathBuf::from_str("/etc/stackable/config").unwrap();
464+
465+
let output = config_dir
466+
.join(&CreatingConfig::render_config_template(&template_data, input).unwrap());
467+
468+
let output = output.to_string_lossy();
469+
assert_eq!(output, expected_output);
470+
}
448471
}

0 commit comments

Comments
 (0)