From d7dfe0252dd4a3a021ec4c7b390f512f1fb8ce67 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Wed, 10 Aug 2022 10:01:10 +0100 Subject: [PATCH] test: add more tests to configuration --- src/config.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/config.rs b/src/config.rs index 8e79c45e..005705f7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -197,6 +197,26 @@ mod tests { config } + #[test] + fn configuration_should_have_default_values() { + use crate::Configuration; + + let configuration = Configuration::default(); + + let toml = toml::to_string(&configuration).expect("Could not encode TOML value"); + + assert_eq!(toml, default_config_toml()); + } + + #[test] + fn configuration_should_contain_the_external_ip() { + use crate::Configuration; + + let configuration = Configuration::default(); + + assert_eq!(configuration.external_ip, Option::Some(String::from("0.0.0.0"))); + } + #[test] fn configuration_should_be_saved_in_a_toml_config_file() { use std::env; @@ -253,4 +273,13 @@ mod tests { assert_eq!(configuration, Configuration::default()); } + + #[test] + fn configuration_error_could_be_displayed() { + use crate::ConfigurationError; + + let error = ConfigurationError::TrackerModeIncompatible; + + assert_eq!(format!("{}", error), "TrackerModeIncompatible"); + } } \ No newline at end of file