Skip to content

Commit 9b86c50

Browse files
committed
test: parse all example configs in unit tests
1 parent 8f9efb9 commit 9b86c50

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

testnet/stacks-node/src/config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,8 @@ pub struct InitialBalanceFile {
28142814

28152815
#[cfg(test)]
28162816
mod tests {
2817+
use std::path::Path;
2818+
28172819
use super::*;
28182820

28192821
#[test]
@@ -3000,6 +3002,26 @@ mod tests {
30003002
}
30013003
}
30023004

3005+
#[test]
3006+
fn test_example_confs() {
3007+
// For each config file in the ../conf/ directory, we should be able to parse it
3008+
let conf_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("conf");
3009+
println!("Reading config files from: {:?}", conf_dir);
3010+
let conf_files = fs::read_dir(conf_dir).unwrap();
3011+
3012+
for entry in conf_files {
3013+
let entry = entry.unwrap();
3014+
let path = entry.path();
3015+
if path.is_file() {
3016+
let file_name = path.file_name().unwrap().to_str().unwrap();
3017+
if file_name.ends_with(".toml") {
3018+
let _config = ConfigFile::from_path(path.to_str().unwrap()).unwrap();
3019+
debug!("Parsed config file: {}", file_name);
3020+
}
3021+
}
3022+
}
3023+
}
3024+
30033025
#[test]
30043026
fn should_load_legacy_mstx_balances_toml() {
30053027
let config = ConfigFile::from_str(

0 commit comments

Comments
 (0)