🐝 My patches for macos etc...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
878 B

  1. use melib;
  2. use melib::email::Draft;
  3. #[test]
  4. fn build_draft() {
  5. let mut new_draft = Draft::default();
  6. let attachment = melib::email::attachment_from_file(&"./tests/test_image.gif")
  7. .expect("Could not open test_image.gif.");
  8. new_draft.headers_mut().remove("User-Agent");
  9. new_draft.headers_mut().remove("Date");
  10. new_draft.attachments_mut().push(attachment);
  11. new_draft.set_body("hello world.".to_string());
  12. let raw = new_draft.finalise().expect("could not finalise draft");
  13. let boundary_def = raw.find("bzz_bzz__bzz__").unwrap();
  14. let boundary_end = boundary_def + raw[boundary_def..].find("\"").unwrap();
  15. let boundary = raw[boundary_def..boundary_end].to_string();
  16. let boundary_str = &boundary["bzz_bzz__bzz__".len()..];
  17. let raw = raw.replace(boundary_str, "");
  18. assert_eq!(include_str!("generated_email.eml"), &raw);
  19. }