init integration tests

This commit is contained in:
Clément DOUIN 2021-05-02 23:49:20 +02:00
parent 8e98895d5b
commit 364654e1ce
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
6 changed files with 84 additions and 4 deletions

View file

@ -1,2 +1,2 @@
pub(crate) mod cli;
pub(crate) mod model;
pub mod model;

View file

@ -1,2 +1,2 @@
pub(crate) mod cli;
pub(crate) mod model;
pub mod model;

11
src/lib.rs Normal file
View file

@ -0,0 +1,11 @@
pub mod app;
pub mod comp;
pub mod config;
pub mod flag;
pub mod imap;
pub mod input;
pub mod mbox;
pub mod msg;
pub mod output;
pub mod smtp;
pub mod table;

View file

@ -1,2 +1,2 @@
pub(crate) mod cli;
pub(crate) mod model;
pub mod model;

69
tests/imap_test.rs Normal file
View file

@ -0,0 +1,69 @@
extern crate himalaya;
use himalaya::{config::model::Account, imap::model::ImapConnector, msg::model::Msgs, smtp};
fn get_account(addr: &str) -> Account {
Account {
name: None,
downloads_dir: None,
signature: None,
default_page_size: None,
default: Some(true),
email: addr.into(),
imap_host: String::from("localhost"),
imap_port: 3993,
imap_starttls: Some(false),
imap_insecure: Some(true),
imap_login: addr.into(),
imap_passwd_cmd: String::from("echo 'password'"),
smtp_host: String::from("localhost"),
smtp_port: 3465,
smtp_starttls: Some(false),
smtp_insecure: Some(true),
smtp_login: addr.into(),
smtp_passwd_cmd: String::from("echo 'password'"),
}
}
#[test]
fn mbox() {
let account = get_account("inbox@localhost");
let mut imap_conn = ImapConnector::new(&account).unwrap();
let mboxes: Vec<String> = imap_conn
.list_mboxes()
.unwrap()
.0
.into_iter()
.map(|mbox| mbox.name)
.collect();
assert_eq!(mboxes, vec![String::from("INBOX")]);
imap_conn.logout();
}
#[test]
fn msg() {
let account = get_account("inbox@localhost");
// Let's add message
smtp::send(
&account,
&lettre::Message::builder()
.from("sender@localhost".parse().unwrap())
.to("inbox@localhost".parse().unwrap())
.subject("Very important message")
.singlepart(
lettre::message::SinglePart::builder().body("Hello, world!".as_bytes().to_vec()),
)
.unwrap(),
)
.unwrap();
// We should see the message
let mut imap_conn = ImapConnector::new(&account).unwrap();
let msgs = imap_conn.list_msgs("INBOX", &10, &0).unwrap();
let msgs = Msgs::from(&msgs);
assert_eq!(msgs.0.len(), 1);
let msg = msgs.0.first().unwrap();
assert_eq!("Very important message", msg.subject.as_str());
imap_conn.logout();
}

2
wiki

@ -1 +1 @@
Subproject commit 8cc2376ccbf69fe256935c186ec7140359b845e0
Subproject commit 9de3caecf8c003285a97f499676c1f28a557876b