~necaris/rust-me-a-question

9c5f1444ce31f40d532aa32524afeb3dbe136945 — Rami Chowdhury 2 years ago 7d20856 main
Add some config tests, TODOs
1 files changed, 18 insertions(+), 1 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +18 -1
@@ 15,9 15,9 @@ mod sleep_range_type;
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
    /// Path of the config file
    #[clap(short, long)]
    config_path: String,
    // TODO: add command, choices, sleep range
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]


@@ 77,3 77,20 @@ fn main() {
            });
    }
}

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

    #[test]
    fn cfg_from_yaml() {
        let maybe_config =
            Config::from_yaml::<&str, serde_yaml::Error>("./fixtures/sample.yml").ok();
        assert!(maybe_config.is_some());
        let config = maybe_config.unwrap();
        assert_eq!(config.sleep.min, 3);
        assert_eq!(config.sleep.max, 15);
        assert_eq!(config.choices.len(), 7);
        assert_eq!(config.choices[0].name, "Who wrote the Declaration of Independence?");
    }
}