Showing the changes to git-object/tests/immutable/commit/message.rs (1 of 3 files). Show all
Unified · Split
| @@ -132,7 +132,10 @@ fn title_with_windows_separator_and_empty_body() { · 131 unmodified lines | |||
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | mod body { | 134 | mod body { |
| 135 | use git_object::commit::{message::BodyRef, MessageRef}; | 135 | use git_object::commit::{ |
| 136 | message::{body::TrailerRef, BodyRef}, | ||
| 137 | MessageRef, | ||
| 138 | }; | ||
| 136 | 139 | ||
| 137 | fn body(input: &str) -> BodyRef<'_> { | 140 | fn body(input: &str) -> BodyRef<'_> { |
| 138 | BodyRef::from_bytes(input.as_bytes()) | 141 | BodyRef::from_bytes(input.as_bytes()) |
| @@ -175,6 +178,20 @@ mod body { · 36 unmodified lines | |||
| 175 | assert_eq!(body(input).as_ref(), input); | 178 | assert_eq!(body(input).as_ref(), input); |
| 176 | } | 179 | } |
| 177 | 180 | ||
| 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 | |||
| 178 | #[test] | 195 | #[test] |
| 179 | fn no_trailer_after_a_paragraph_windows() { | 196 | fn no_trailer_after_a_paragraph_windows() { |
| 180 | let input = "foo\nbar\n\nbar\r\n\r\nbaz"; | 197 | let input = "foo\nbar\n\nbar\r\n\r\nbaz"; |