Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
vhdirk committed Nov 16, 2019
1 parent e16769c commit 3b92173
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 221 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "notmuch"
version = "0.5.0"
version = "0.6.0"
authors = ["Dirk Van Haerenborgh <vhdirk@gmail.com>"]
homepage = "https://github.com/vhdirk/notmuch-rs"
repository = "https://github.com/vhdirk/notmuch-rs"
Expand Down
6 changes: 1 addition & 5 deletions src/config_list.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use std::ops::Drop;
use std::ffi::{CStr, CString};
use supercow::Supercow;

use ffi;
use Database;
use Filenames;
use FilenamesOwner;
use utils::{ToStr, ScopedSupercow, ScopedPhantomcow};
use utils::{ToStr, ScopedPhantomcow};


#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl std::error::Error for Error {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
Error::IoError(ref e) => Some(e),
Error::NotmuchError(ref e) => Some(e),
Expand Down
7 changes: 2 additions & 5 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use std::ops::Drop;
use supercow::{Supercow, Phantomcow};

use error::{Error, Result};
use error::Result;
use ffi;
use ffi::DecryptionPolicy;
use Database;
use Filenames;
use FilenamesOwner;
use utils::{ScopedSupercow, ScopedPhantomcow};
use utils::ScopedPhantomcow;


#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::ffi::{CString, CStr};
use std::path::{Path, PathBuf};
use std::ffi::CString;
use std::path::PathBuf;
use std::cell::RefCell;
use std::borrow::Cow;
use std::ptr;
Expand Down
5 changes: 2 additions & 3 deletions src/message_properties.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::ops::Drop;
use std::ffi::{CStr, CString};
use supercow::Supercow;
use std::ffi::CStr;

use ffi;
use Message;
use MessageOwner;
use utils::{ScopedSupercow, ScopedPhantomcow};
use utils::{ScopedPhantomcow};


#[derive(Debug)]
Expand Down
2 changes: 0 additions & 2 deletions src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::ops::Drop;

use ffi;
use utils::ScopedPhantomcow;
use MessageOwner;
Expand Down
6 changes: 1 addition & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::borrow::Cow;
use supercow::{Supercow, DefaultFeatures/*, NonSyncFeatures*/};
use supercow::ext::{BoxedStorage};


pub trait ToStr {
fn to_str<'a>(&self) -> Result<&'a str, str::Utf8Error>;

Expand Down Expand Up @@ -48,8 +49,3 @@ pub type ScopedPhantomcow<'a, OWNED, BORROWED = OWNED,

pub type ScopedSupercow<'a, OWNED, BORROWED = OWNED, SHARED = Box<dyn DefaultFeatures<'a> + 'a>> =
Supercow<'a, OWNED, BORROWED, SHARED, BoxedStorage>;





140 changes: 0 additions & 140 deletions tests/commands.rs

This file was deleted.

49 changes: 6 additions & 43 deletions tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,23 @@ extern crate lettre;
extern crate lettre_email;

use std::ffi::OsStr;
use std::io::{self, Result, Write};
use std::io::{Result, Write};
use std::fs::{self, File};
use std::rc::Rc;
use std::path::{Path, PathBuf};
use tempfile::{tempdir, tempdir_in, Builder, TempDir};
use std::net::ToSocketAddrs;
use std::path::PathBuf;
use tempfile::{tempdir, TempDir};
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
use maildir::Maildir;
use lettre_email::{EmailBuilder, Header};
use lettre::SendableEmail;


pub fn timestamp_ms() -> u128 {
let start = SystemTime::now();
let time_since_epoch = start.duration_since(UNIX_EPOCH).unwrap();
time_since_epoch.as_millis()
}

// A basic test interface to a valid maildir directory.
//
// This creates a valid maildir and provides a simple mechanism to
// deliver test emails to it. It also writes a notmuch-config file
// in the top of the maildir.
pub struct MailBox {
root_dir: TempDir,
idcount: u32,
maildir: Maildir
}

Expand Down Expand Up @@ -73,7 +63,6 @@ impl MailBox {

Self {
root_dir,
idcount: 0,
maildir
}
}
Expand All @@ -86,16 +75,10 @@ impl MailBox {
// msgid
// }

pub fn path(&self) -> PathBuf
{
pub fn path(&self) -> PathBuf {
self.root_dir.path().into()
}

pub fn hostname(&self) -> String {
let hname = gethostname::gethostname();
hname.to_string_lossy().into()
}

/// Deliver a new mail message in the mbox.
/// This does only adds the message to maildir, does not insert it
/// into the notmuch database.
Expand All @@ -107,7 +90,7 @@ impl MailBox {
from: Option<String>,
headers: Vec<(String, String)>,
is_new: bool, // Move to new dir or cur dir?
keywords: Option<Vec<String>>, // List of keywords or labels
_keywords: Option<Vec<String>>, // List of keywords or labels
seen: bool, // Seen flag (cur dir only)
replied: bool, // Replied flag (cur dir only)
flagged: bool) // Flagged flag (cur dir only)
Expand Down Expand Up @@ -154,27 +137,7 @@ impl MailBox {
format!("{}:2,{}", mid, flags)
};

// let mut flags = String::from("");
// if flagged {
// flags += "F";
// }
// if replied {
// flags += "R";
// }
// if seen {
// flags += "S";
// }
// println!("flags: {:?}", flags);
// let id = self.maildir.store_cur_with_flags(&msg.message_to_string().unwrap().as_bytes(), flags.as_str()).unwrap();

// if is_new {
// let msgpath = format!("{}{}", id, flags);
// std::fs::rename(msgpath, newpath)?;

// self.maildir.path()
// }



let mut msgpath = self.path();
msgpath = if is_new {
msgpath.join("new")
Expand Down
5 changes: 3 additions & 2 deletions tests/test_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod database {


mod atomic {
use super::*;
// use super::*;

// TODO: how do I test this??

Expand All @@ -107,6 +107,7 @@ mod revision {
assert!(rev0 == rev1);
assert!(rev0 <= rev1);
assert!(rev0 >= rev1);

assert!(!(rev0 < rev1));
assert!(!(rev0 > rev1));
}
Expand Down Expand Up @@ -176,7 +177,7 @@ mod messages {
let db = notmuch::Database::create(&mailbox.path()).unwrap();

let (msgid, filename) = mailbox.deliver(None, None, None, None, vec![], true, None, false, false, false).unwrap();
let msg = db.index_file(&filename, None).unwrap();
db.index_file(&filename, None).unwrap();
assert!(db.find_message(&msgid).unwrap().is_some());

db.remove_message(&filename).unwrap();
Expand Down
Loading

0 comments on commit 3b92173

Please sign in to comment.