Skip to content

Commit

Permalink
Added unit test to config.rs.
Browse files Browse the repository at this point in the history
  • Loading branch information
RRArny committed Nov 15, 2024
1 parent ff1a4ed commit 2e19616
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[position]
airfield = "EDRK"
# airfield = "EDRK"

[clouds]
cloud_minimum = 6
Expand Down
13 changes: 13 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{
Args, Secrets,
};

#[derive(PartialEq, Debug)]
pub struct Config {
pub position: Position,
pub cloud_minimum: i64,
Expand Down Expand Up @@ -185,3 +186,15 @@ fn read_config_file(config_filepath: Option<String>) -> Config {

config
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_read_config_file() {
let expected = Config::default();
let actual = read_config_file(Some("./config.toml".to_string()));
assert_eq!(expected, actual);
}
}
4 changes: 2 additions & 2 deletions src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use serde_json::Value;
use std::fmt::Display;

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum Position {
Airfield(String),
GeoIP,
Expand All @@ -33,7 +33,7 @@ impl Position {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, PartialEq, Clone)]
pub struct LatLong(pub f64, pub f64);

impl Display for LatLong {
Expand Down

0 comments on commit 2e19616

Please sign in to comment.