History

feat: `BodyRef::trailers()` allows iterating trailer tokens and values (#198)

Sebastian Thiel committed 5 years ago

Commit 175e1cb1 parent 3953c243 files · +103 −11Browse files

Showing the changes to git-object/tests/immutable/commit (2 of 3 files). Show all

Unified · Split

2 files
  1. git-object/tests/immutable/commit/from_bytes.rs +1 −2
  2. git-object/tests/immutable/commit/message.rs +18 −1
git-object/tests/immutable/commit/from_bytes.rs+1−2
@@ -134,8 +134,7 @@ fn with_encoding() -> crate::Result { · 133 unmodified lines
134134 }
135135
136136 #[test]
137−#[ignore]
138−fn with_footer() -> crate::Result {
137+fn with_trailer() -> crate::Result {
139138 let kim = SignatureRef {
140139 name: "Kim Altintop".into(),
141140 email: "kim@eagain.st".into(),
git-object/tests/immutable/commit/message.rs+18−1
@@ -132,7 +132,10 @@ fn title_with_windows_separator_and_empty_body() { · 131 unmodified lines
132132 }
133133
134134 mod body {
135− use git_object::commit::{message::BodyRef, MessageRef};
135+ use git_object::commit::{
136+ message::{body::TrailerRef, BodyRef},
137+ MessageRef,
138+ };
136139
137140 fn body(input: &str) -> BodyRef<'_> {
138141 BodyRef::from_bytes(input.as_bytes())
@@ -175,6 +178,20 @@ mod body { · 36 unmodified lines
175178 assert_eq!(body(input).as_ref(), input);
176179 }
177180
181+ #[test]
182+ fn single_trailer_after_a_few_paragraphs() {
183+ let input = "foo\nbar\n\nbar\n\nbaz\n\ntoken: value";
184+ let body = body(input);
185+ assert_eq!(body.as_ref(), "foo\nbar\n\nbar\n\nbaz");
186+ assert_eq!(
187+ body.trailers().collect::<Vec<_>>(),
188+ vec![TrailerRef {
189+ token: "token".into(),
190+ value: "value".into()
191+ }]
192+ )
193+ }
194+
178195 #[test]
179196 fn no_trailer_after_a_paragraph_windows() {
180197 let input = "foo\nbar\n\nbar\r\n\r\nbaz";