use conventional_commit_parser::commit::{Footer, Separator};
use indoc::indoc;
use speculoos::prelude::*;
#[test]
pub fn parse_footer_only() {
let footers = indoc!(
"a-token: this is a token
another-token #this is a token with hash separator"
);
let parsed = conventional_commit_parser::parse_footers(footers);
assert_that(&parsed).is_ok().contains_all_of(&vec![
&Footer {
token: "a-token".to_string(),
content: "this is a token".to_string(),
..Default::default()
},
&Footer {
token: "another-token".to_string(),
content: "this is a token with hash separator".to_string(),
token_separator: Separator::Hash,
},
]);
}
#[test]
pub fn parse_footer_with_new_lines() {
let footers = indoc!(
"updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-parent
dependency-type: direct:production
update-type: version-update:semver-patch
..."
);
let parsed = conventional_commit_parser::parse_footers(footers);
assert_that(&parsed).is_ok().contains_all_of(&vec![&Footer {
token: "updated-dependencies".to_string(),
content: indoc!(
"- dependency-name: org.springframework.boot:spring-boot-starter-parent
dependency-type: direct:production
update-type: version-update:semver-patch
..."
)
.to_string(),
token_separator: Separator::ColonWithNewLine,
}]);
}