@@ 212,6 212,16 @@ impl Entry {
mod tests {
use super::*;
use serial_test::serial;
+ use std::io::Write;
+
+ fn create_dummy_mailcap_line() -> (PathBuf, String) {
+ let path = PathBuf::from("/tmp/mailcap-rs.test");
+ let mut dummy_file = File::create(&path).unwrap();
+ let dummy_value = String::from("text/html; qutebrowser '%s'; test=test -n \"$DISPLAY\"; nametemplate=%s.html; needsterminal");
+ write!(&mut dummy_file, "{}", dummy_value).unwrap();
+
+ (path, dummy_value)
+ }
#[test]
#[serial]
@@ 314,4 324,18 @@ mod tests {
entry
)
}
+
+ #[test]
+ #[serial]
+ fn create_mailcap_struct() {
+ let (_path, dummy_line) = create_dummy_mailcap_line();
+ let dummy_line_vectorized = Mailcap::parse_valid_lines(vec![dummy_line]).unwrap();
+ let dummy_line = Entry::from(dummy_line_vectorized[0].to_owned());
+
+ env::set_var("MAILCAPS", "/tmp/mailcap-rs.test");
+ let mailcap = Mailcap::new().unwrap();
+ if let Some(i) = mailcap.data.get("text/html") {
+ assert_eq!(i.command, dummy_line.command)
+ }
+ }
}