Skip to content

Commit 35c3be0

Browse files
committed
Add a couple of tests
1 parent 674e520 commit 35c3be0

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
/.rust/
2-
/build/
3-
/bin/
41
/doc/
5-
/lib/
2+
/lib

tests.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ use super::{PostgresNoticeHandler,
2121
PostgresDbError,
2222
PostgresStatement,
2323
ResultDescription};
24-
use super::error::hack::{SyntaxError, InvalidPassword, QueryCanceled};
24+
use super::error::hack::{SyntaxError,
25+
InvalidPassword,
26+
QueryCanceled,
27+
InvalidCatalogName};
2528
use super::types::{ToSql, FromSql, PgInt4, PgVarchar};
2629
use super::pool::PostgresConnectionPool;
2730

@@ -55,6 +58,11 @@ fn test_non_default_database() {
5558
PostgresConnection::connect("postgres://postgres@localhost/postgres");
5659
}
5760

61+
#[test]
62+
fn test_url_terminating_slash() {
63+
PostgresConnection::connect("postgres://postgres@localhost/");
64+
}
65+
5866
#[test]
5967
fn test_prepare_err() {
6068
let conn = PostgresConnection::connect("postgres://postgres@localhost");
@@ -64,6 +72,14 @@ fn test_prepare_err() {
6472
}
6573
}
6674

75+
#[test]
76+
fn test_unknown_database() {
77+
match PostgresConnection::try_connect("postgres://postgres@localhost/asdf") {
78+
Err(DbError(PostgresDbError { code: InvalidCatalogName, _ })) => {}
79+
resp => fail!("Unexpected result {:?}", resp)
80+
}
81+
}
82+
6783
#[test]
6884
fn test_transaction_commit() {
6985
let conn = PostgresConnection::connect("postgres://postgres@localhost");

0 commit comments

Comments
 (0)