From cd613a0c392d973d5c7afb21234b75b5201eb47a Mon Sep 17 00:00:00 2001 From: Mack Solomon Date: Wed, 19 Apr 2023 19:23:22 -0700 Subject: [PATCH] tests: add a copule env override assertions --- git-cliff-core/src/config.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/git-cliff-core/src/config.rs b/git-cliff-core/src/config.rs index 0b1da5ae22..15abb5281e 100644 --- a/git-cliff-core/src/config.rs +++ b/git-cliff-core/src/config.rs @@ -166,9 +166,29 @@ mod test { .to_path_buf() .join("config") .join(crate::DEFAULT_CONFIG); - env::set_var("CLIFF_GIT__CHANGELOG__FOOTER", "test"); + + const FOOTER_VALUE: &str = "test"; + const TAG_PATTERN_VALUE: &str = "*[0-9]*"; + const IGNORE_TAGS_VALUE: &str = "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"; + + env::set_var("CLIFF_GIT__CHANGELOG__FOOTER", FOOTER_VALUE); + env::set_var("CLIFF_GIT__GIT__TAG_PATTERN", TAG_PATTERN_VALUE); + env::set_var("CLIFF_GIT__GIT__IGNORE_TAGS", IGNORE_TAGS_VALUE); + let config = Config::parse(&path)?; - assert_eq!(Some(String::from("test")), config.changelog.footer); + + assert_eq!(Some(String::from(FOOTER_VALUE)), config.changelog.footer); + assert_eq!( + Some(String::from(TAG_PATTERN_VALUE)), + config.git.tag_pattern + ); + assert_eq!( + Some(String::from(IGNORE_TAGS_VALUE)), + config + .git + .ignore_tags + .map(|ignore_tags| ignore_tags.to_string()) + ); Ok(()) } }