Skip to content

Commit

Permalink
tests: add a copule env override assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
mackness committed Apr 20, 2023
1 parent 7f4d215 commit cd613a0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

0 comments on commit cd613a0

Please sign in to comment.