Skip to content

Commit bb0b628

Browse files
committed
move: example config test to config.rs
1 parent edeefca commit bb0b628

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,25 @@ fn parse_toml_node(toml_node: &TomlNode) -> Result<BoxedSyncSendNode, ConfigErro
290290
};
291291
Ok(node)
292292
}
293+
294+
#[cfg(test)]
295+
mod tests {
296+
297+
#[test]
298+
fn load_example_config() {
299+
use crate::config;
300+
use std::env;
301+
302+
const FILENAME_EXAMPLE_CONFIG: &str = "config.toml.example";
303+
env::set_var(config::ENVVAR_CONFIG_FILE, FILENAME_EXAMPLE_CONFIG);
304+
let cfg = config::load_config().expect(&format!(
305+
"We should be able to load the {} file.",
306+
FILENAME_EXAMPLE_CONFIG
307+
));
308+
309+
assert_eq!(cfg.address.to_string(), "127.0.0.1:2323");
310+
assert_eq!(cfg.networks.len(), 2);
311+
assert_eq!(cfg.query_interval, std::time::Duration::from_secs(15));
312+
assert_eq!(cfg.networks[0].pool_identification.enable, true);
313+
}
314+
}

src/main.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -595,25 +595,3 @@ async fn tip_heights(network_id: u32, caches: &Caches) -> BTreeSet<u64> {
595595
}
596596
tip_heights
597597
}
598-
599-
#[cfg(test)]
600-
mod tests {
601-
602-
#[test]
603-
fn load_example_config() {
604-
use crate::config;
605-
use std::env;
606-
607-
const FILENAME_EXAMPLE_CONFIG: &str = "config.toml.example";
608-
env::set_var(config::ENVVAR_CONFIG_FILE, FILENAME_EXAMPLE_CONFIG);
609-
let cfg = config::load_config().expect(&format!(
610-
"We should be able to load the {} file.",
611-
FILENAME_EXAMPLE_CONFIG
612-
));
613-
614-
assert_eq!(cfg.address.to_string(), "127.0.0.1:2323");
615-
assert_eq!(cfg.networks.len(), 2);
616-
assert_eq!(cfg.query_interval, std::time::Duration::from_secs(15));
617-
assert_eq!(cfg.networks[0].pool_identification.enable, true);
618-
}
619-
}

0 commit comments

Comments
 (0)