History

feat: `CommitRef::message_trailers()` as shortcut… (#198)

…which also saves parsing time.

Sebastian Thiel committed 5 years ago

Commit 53243911 parent c3b01614 files · +36 −12Browse files

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

Unified · Split

2 files
  1. git-object/tests/immutable/commit/from_bytes.rs +20 −2
  2. git-object/tests/immutable/commit/message.rs +1 −1
git-object/tests/immutable/commit/from_bytes.rs+20−2
@@ -1,5 +1,5 @@
11 use git_actor::{Sign, SignatureRef, Time};
2−use git_object::{bstr::ByteSlice, CommitRef};
2+use git_object::{bstr::ByteSlice, commit::message::body::TrailerRef, CommitRef};
33 use smallvec::SmallVec;
44
55 use crate::immutable::{
@@ -185,7 +185,7 @@ Signed-off-by: Kim Altintop <kim@eagain.st>" · 179 unmodified lines
185185 )
186186 );
187187 assert_eq!(
188− commit.summary(),
188+ commit.message_summary(),
189189 message.summary(),
190190 "both summaries are the same, but the commit one does less parsing"
191191 );
@@ -200,6 +200,24 @@ instead of depending directly on the lower-level crates. · 8 unmodified lines
200200 .as_bstr(),
201201 "body doesn't contain footer"
202202 );
203+ assert_eq!(
204+ body.trailers().collect::<Vec<_>>(),
205+ vec![
206+ TrailerRef {
207+ token: "Signed-off-by".into(),
208+ value: "Sebastian Thiel <sebastian.thiel@icloud.com>".into()
209+ },
210+ TrailerRef {
211+ token: "Signed-off-by".into(),
212+ value: "Kim Altintop <kim@eagain.st>".into()
213+ }
214+ ]
215+ );
216+ assert_eq!(
217+ body.trailers().collect::<Vec<_>>(),
218+ commit.message_trailers().collect::<Vec<_>>(),
219+ "messages trailers are accessible on commit level and yield the same result"
220+ );
203221 Ok(())
204222 }
205223
git-object/tests/immutable/commit/message.rs+1−1
@@ -250,7 +250,7 @@ mod summary { · 249 unmodified lines
250250 message: input.as_bstr(),
251251 extra_headers: vec![]
252252 }
253− .summary(),
253+ .message_summary(),
254254 summary,
255255 "both versions create the same result"
256256 );