maik 0.2.0

A mock SMTP server library
Documentation
use crate::helpers::{
    new_message, TestInfoBuilder, DEFAULT_BODY, DEFAULT_MESSAGES, DEFAULT_RECIPIENT,
    DEFAULT_RECIPIENTS_SET, DEFAULT_SENDER, EMPTY_MESSAGE,
};
use lettre::{transport::smtp::client::Tls, Transport};
use maik::MailAssertion;

#[test]
fn sender_recipient_body() {
    let test_info = TestInfoBuilder::new().default_auth_user().build();
    let mailer = test_info.mailer_builder.tls(Tls::None).build();
    assert!(mailer.send(&DEFAULT_MESSAGES).is_ok());

    let ma = MailAssertion::new()
        .sender_is(DEFAULT_SENDER)
        .recipients_are(DEFAULT_RECIPIENTS_SET.iter())
        .body_is(DEFAULT_BODY);

    assert!(test_info.server.assert(ma));
}

#[test]
fn sender_body_but_with_recipients_from_another_mail() {
    let test_info = TestInfoBuilder::new().default_auth_user().build();
    let mailer = test_info.mailer_builder.tls(Tls::None).build();
    assert!(mailer.send(&EMPTY_MESSAGE).is_ok());
    let message = new_message("someone_else@domain2.com", DEFAULT_BODY);
    assert!(mailer.send(&message).is_ok());

    let ma = MailAssertion::new()
        .sender_is(DEFAULT_SENDER)
        .recipients_are([DEFAULT_RECIPIENT])
        .body_is(DEFAULT_BODY);

    assert!(!test_info.server.assert(ma));
}