Skip to content

Commit

Permalink
test: add more tests to configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Aug 10, 2022
1 parent 749e896 commit d7dfe02
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
}

0 comments on commit d7dfe02

Please sign in to comment.