Update tests to follow rust upgrade
This commit is contained in:
@@ -8,14 +8,14 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(default_type_params)]
|
||||
#![feature(phase)] #[phase(plugin, link)] extern crate log;
|
||||
#[macro_use] extern crate log;
|
||||
|
||||
extern crate smtp;
|
||||
extern crate getopts;
|
||||
|
||||
use std::io::stdin;
|
||||
use std::old_io::stdin;
|
||||
use std::string::String;
|
||||
use std::io::net::ip::Port;
|
||||
use std::old_io::net::ip::Port;
|
||||
use std::os;
|
||||
use getopts::{optopt, optflag, getopts, OptGroup, usage};
|
||||
|
||||
@@ -35,7 +35,7 @@ fn sendmail(source_address: &str, recipient_addresses: &[&str], message: &str, s
|
||||
email.subject(subject);
|
||||
email.date_now();
|
||||
|
||||
let mut client = Client::new((server, port));
|
||||
let mut client: Client = Client::new((server, port));
|
||||
client.set_hello_name(my_hostname);
|
||||
client.send(email)
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ mod test {
|
||||
assert_eq!(format!("{}", ServerInfo{
|
||||
name: "name".to_string(),
|
||||
esmtp_features: Some(vec![Extension::EightBitMime])
|
||||
}), "name with [8BITMIME]".to_string());
|
||||
}), "name with [EightBitMime]".to_string());
|
||||
assert_eq!(format!("{}", ServerInfo{
|
||||
name: "name".to_string(),
|
||||
esmtp_features: Some(vec![Extension::EightBitMime, Extension::Size(42)])
|
||||
}), "name with [8BITMIME, SIZE=42]".to_string());
|
||||
}), "name with [EightBitMime, Size(42)]".to_string());
|
||||
assert_eq!(format!("{}", ServerInfo{
|
||||
name: "name".to_string(),
|
||||
esmtp_features: None
|
||||
|
||||
@@ -120,12 +120,12 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_from_str() {
|
||||
assert_eq!("8BITMIME".parse::<Extension>(), Some(Extension::EightBitMime));
|
||||
assert_eq!("SIZE 42".parse::<Extension>(), Some(Extension::Size(42)));
|
||||
assert_eq!("SIZ 42".parse::<Extension>(), None);
|
||||
assert_eq!("SIZE 4a2".parse::<Extension>(), None);
|
||||
assert_eq!("8BITMIME".parse::<Extension>(), Ok(Extension::EightBitMime));
|
||||
assert_eq!("SIZE 42".parse::<Extension>(), Ok(Extension::Size(42)));
|
||||
assert!("SIZ 42".parse::<Extension>().is_err());
|
||||
assert!("SIZE 4a2".parse::<Extension>().is_err());
|
||||
// TODO: accept trailing spaces ?
|
||||
assert_eq!("SIZE 42 ".parse::<Extension>(), None);
|
||||
assert!("SIZE 42 ".parse::<Extension>().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//! email.date_now();
|
||||
//!
|
||||
//! // Open a local connection on port 25
|
||||
//! let mut client = Client::localhost();
|
||||
//! let mut client: Client = Client::localhost();
|
||||
//! // Send the email
|
||||
//! let result = client.send(email);
|
||||
//!
|
||||
@@ -68,7 +68,7 @@
|
||||
//! email.date_now();
|
||||
//!
|
||||
//! // Connect to a remote server on a custom port
|
||||
//! let mut client = Client::new(("server.tld", 10025));
|
||||
//! let mut client: Client = Client::new(("server.tld", 10025));
|
||||
//! // Set the name sent during EHLO/HELO, default is `localhost`
|
||||
//! client.set_hello_name("my.hostname.tld");
|
||||
//! // Enable connection reuse
|
||||
@@ -100,7 +100,7 @@
|
||||
//! "Hello world !"
|
||||
//! );
|
||||
//!
|
||||
//! let mut client = Client::localhost();
|
||||
//! let mut client: Client = Client::localhost();
|
||||
//! let result = client.send(email);
|
||||
//! assert!(result.is_ok());
|
||||
//! ```
|
||||
@@ -114,7 +114,7 @@
|
||||
//! use smtp::client::Client;
|
||||
//! use smtp::common::SMTP_PORT;
|
||||
//!
|
||||
//! let mut email_client = Client::new(("localhost", SMTP_PORT));
|
||||
//! let mut email_client: Client = Client::new(("localhost", SMTP_PORT));
|
||||
//! let _ = email_client.connect();
|
||||
//! let _ = email_client.ehlo();
|
||||
//! let _ = email_client.mail("user@example.com");
|
||||
|
||||
@@ -84,40 +84,40 @@ mod test {
|
||||
#[test]
|
||||
fn test_from_str() {
|
||||
assert_eq!("200 response message".parse::<Response>(),
|
||||
Some(Response{
|
||||
Ok(Response{
|
||||
code: 200,
|
||||
message: Some("response message".to_string())
|
||||
})
|
||||
);
|
||||
assert_eq!("200-response message".parse::<Response>(),
|
||||
Some(Response{
|
||||
Ok(Response{
|
||||
code: 200,
|
||||
message: Some("response message".to_string())
|
||||
})
|
||||
);
|
||||
assert_eq!("200".parse::<Response>(),
|
||||
Some(Response{
|
||||
Ok(Response{
|
||||
code: 200,
|
||||
message: None
|
||||
})
|
||||
);
|
||||
assert_eq!("200 ".parse::<Response>(),
|
||||
Some(Response{
|
||||
Ok(Response{
|
||||
code: 200,
|
||||
message: None
|
||||
})
|
||||
);
|
||||
assert_eq!("200-response\r\nmessage".parse::<Response>(),
|
||||
Some(Response{
|
||||
Ok(Response{
|
||||
code: 200,
|
||||
message: Some("response\r\nmessage".to_string())
|
||||
})
|
||||
);
|
||||
assert_eq!("2000response message".parse::<Response>(), None);
|
||||
assert_eq!("20a response message".parse::<Response>(), None);
|
||||
assert_eq!("20 ".parse::<Response>(), None);
|
||||
assert_eq!("20".parse::<Response>(), None);
|
||||
assert_eq!("2".parse::<Response>(), None);
|
||||
assert_eq!("".parse::<Response>(), None);
|
||||
assert!("2000response message".parse::<Response>().is_err());
|
||||
assert!("20a response message".parse::<Response>().is_err());
|
||||
assert!("20 ".parse::<Response>().is_err());
|
||||
assert!("20".parse::<Response>().is_err());
|
||||
assert!("2".parse::<Response>().is_err());
|
||||
assert!("".parse::<Response>().is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user