diff --git a/.gitignore b/.gitignore index 1472b383..02d639b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/.rust/ /doc/ -/lib +/test diff --git a/.travis.yml b/.travis.yml index d0800de2..c5b48654 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,5 @@ install: before_script: - ./travis/setup.sh script: - - rustc --test --cfg travis -o test lib.rs + - rustc --test --cfg travis test.rs - ./test diff --git a/lib.rs b/lib.rs index 745fcbd3..5a5e8c53 100644 --- a/lib.rs +++ b/lib.rs @@ -82,53 +82,50 @@ use std::rt::io::net::tcp::TcpStream; use std::task; use std::util; -use error::hack::PostgresSqlState; -use message::{BackendMessage, - AuthenticationOk, - AuthenticationKerberosV5, - AuthenticationCleartextPassword, - AuthenticationMD5Password, - AuthenticationSCMCredential, - AuthenticationGSS, - AuthenticationSSPI, - BackendKeyData, - BindComplete, - CommandComplete, - DataRow, - EmptyQueryResponse, - ErrorResponse, - NoData, - NoticeResponse, - NotificationResponse, - ParameterDescription, - ParameterStatus, - ParseComplete, - PortalSuspended, - ReadyForQuery, - RowDescription}; -use message::{FrontendMessage, - Bind, - CancelRequest, - Close, - Describe, - Execute, - Parse, - PasswordMessage, - Query, - StartupMessage, - Sync, - Terminate}; -use message::{RowDescriptionEntry, WriteMessage, ReadMessage}; -use types::{PostgresType, ToSql, FromSql}; +use self::error::hack::PostgresSqlState; +use self::message::{BackendMessage, + AuthenticationOk, + AuthenticationKerberosV5, + AuthenticationCleartextPassword, + AuthenticationMD5Password, + AuthenticationSCMCredential, + AuthenticationGSS, + AuthenticationSSPI, + BackendKeyData, + BindComplete, + CommandComplete, + DataRow, + EmptyQueryResponse, + ErrorResponse, + NoData, + NoticeResponse, + NotificationResponse, + ParameterDescription, + ParameterStatus, + ParseComplete, + PortalSuspended, + ReadyForQuery, + RowDescription}; +use self::message::{FrontendMessage, + Bind, + CancelRequest, + Close, + Describe, + Execute, + Parse, + PasswordMessage, + Query, + StartupMessage, + Sync, + Terminate}; +use self::message::{RowDescriptionEntry, WriteMessage, ReadMessage}; +use self::types::{PostgresType, ToSql, FromSql}; pub mod error; pub mod pool; mod message; pub mod types; -#[cfg(test)] -mod tests; - static DEFAULT_PORT: Port = 5432; /// Trait for types that can handle Postgres notice messages diff --git a/message.rs b/message.rs index b8ea3c0e..b6383e29 100644 --- a/message.rs +++ b/message.rs @@ -6,7 +6,7 @@ use std::rt::io::mem::{MemWriter, MemReader}; use std::mem; use std::vec; -use types::Oid; +use super::types::Oid; pub static PROTOCOL_VERSION: i32 = 0x0003_0000; pub static CANCEL_CODE: i32 = 80877102; diff --git a/tests.rs b/test.rs similarity index 98% rename from tests.rs rename to test.rs index b44033f1..79f5c3a5 100644 --- a/tests.rs +++ b/test.rs @@ -1,3 +1,5 @@ +#[feature(struct_variant, macro_rules, globs)]; + extern mod extra; use extra::comm::DuplexStream; @@ -11,7 +13,7 @@ use std::f32; use std::f64; use std::rt::io::timer; -use super::{PostgresNoticeHandler, +use lib::{PostgresNoticeHandler, PostgresNotification, DbError, DnsError, @@ -21,13 +23,15 @@ use super::{PostgresNoticeHandler, PostgresDbError, PostgresStatement, ResultDescription}; -use super::error::hack::{SyntaxError, +use lib::error::hack::{SyntaxError, InvalidPassword, QueryCanceled, InvalidCatalogName}; -use super::types::{ToSql, FromSql, PgInt4, PgVarchar}; -use super::types::range::{Range, Inclusive, Exclusive, RangeBound}; -use super::pool::PostgresConnectionPool; +use lib::types::{ToSql, FromSql, PgInt4, PgVarchar}; +use lib::types::range::{Range, Inclusive, Exclusive, RangeBound}; +use lib::pool::PostgresConnectionPool; + +mod lib; #[test] // Make sure we can take both connections at once and can still get one after @@ -563,7 +567,7 @@ fn test_cancel_query() { do spawn { timer::sleep(500); - assert!(super::cancel_query("postgres://postgres@localhost", + assert!(lib::cancel_query("postgres://postgres@localhost", cancel_data).is_none()); }