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
134}134}
135 135
136#[test]136#[test]
137#[ignore]137fn with_trailer() -> crate::Result {
138fn with_footer() -> crate::Result {
139 let kim = SignatureRef {138 let kim = SignatureRef {
140 name: "Kim Altintop".into(),139 name: "Kim Altintop".into(),
141 email: "kim@eagain.st".into(),140 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
132}132}
133 133
134mod body {134mod 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";