Fix tests on Travis
This commit is contained in:
parent
db2d81d813
commit
039d02ed58
@ -3,8 +3,10 @@ before_install:
|
||||
- sudo apt-get update
|
||||
install:
|
||||
- sudo apt-get install rust-nightly
|
||||
before_script:
|
||||
- ./travis/setup.sh
|
||||
script:
|
||||
- rustc --lib --out-dir . src/postgres/lib.rs
|
||||
- rustc --test --out-dir . -L. src/postgres/test.rs
|
||||
- rustc --test --out-dir . -L. --cfg travis src/postgres/test.rs
|
||||
- ./test
|
||||
# - rustpkg test postgres
|
||||
|
@ -283,6 +283,7 @@ fn test_bytea_params() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(travis))] // Travis runs Postgres 9.1
|
||||
fn test_json_params() {
|
||||
test_type("JSON", [(Some(json::from_str("[10, 11, 12]").unwrap()),
|
||||
"'[10, 11, 12]'"),
|
||||
@ -418,7 +419,8 @@ fn test_plaintext_pass_no_pass() {
|
||||
let ret = PostgresConnection::try_connect("postgres://pass_user@localhost");
|
||||
match ret {
|
||||
Err(MissingPassword) => (),
|
||||
ret => fail!("Unexpected result %?", ret)
|
||||
Err(err) => fail2!("Unexpected error {}", err.to_str()),
|
||||
_ => fail2!("Expected error")
|
||||
}
|
||||
}
|
||||
|
||||
@ -427,7 +429,8 @@ fn test_plaintext_pass_wrong_pass() {
|
||||
let ret = PostgresConnection::try_connect("postgres://pass_user:asdf@localhost");
|
||||
match ret {
|
||||
Err(DbError(PostgresDbError { code: InvalidPassword, _ })) => (),
|
||||
ret => fail!("Unexpected result %?", ret)
|
||||
Err(err) => fail2!("Unexpected error {}", err.to_str()),
|
||||
_ => fail2!("Expected error")
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +444,8 @@ fn test_md5_pass_no_pass() {
|
||||
let ret = PostgresConnection::try_connect("postgres://md5_user@localhost");
|
||||
match ret {
|
||||
Err(MissingPassword) => (),
|
||||
ret => fail!("Unexpected result %?", ret)
|
||||
Err(err) => fail2!("Unexpected error {}", err.to_str()),
|
||||
_ => fail2!("Expected error")
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,7 +454,8 @@ fn test_md5_pass_wrong_pass() {
|
||||
let ret = PostgresConnection::try_connect("postgres://md5_user:asdf@localhost");
|
||||
match ret {
|
||||
Err(DbError(PostgresDbError { code: InvalidPassword, _ })) => (),
|
||||
ret => fail!("Unexpected result %?", ret)
|
||||
Err(err) => fail2!("Unexpected error {}", err.to_str()),
|
||||
_ => fail2!("Expected error")
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,6 +464,7 @@ fn test_dns_failure() {
|
||||
let ret = PostgresConnection::try_connect("postgres://postgres@asdfasdfasdf");
|
||||
match ret {
|
||||
Err(DnsError) => (),
|
||||
ret => fail!("Unexpected result %?", ret)
|
||||
Err(err) => fail2!("Unexpected error {}", err.to_str()),
|
||||
_ => fail2!("Expected error")
|
||||
}
|
||||
}
|
||||
|
10
travis/pg_hba.conf
Normal file
10
travis/pg_hba.conf
Normal file
@ -0,0 +1,10 @@
|
||||
# TYPE DATABASE USER ADDRESS METHOD
|
||||
host all pass_user 127.0.0.1/32 password
|
||||
host all md5_user 127.0.0.1/32 md5
|
||||
host all pass_user ::1/128 password
|
||||
host all md5_user ::1/128 md5
|
||||
|
||||
# IPv4 local connections:
|
||||
host all postgres 127.0.0.1/32 trust
|
||||
# IPv6 local connections:
|
||||
host all postgres ::1/128 trust
|
12
travis/setup.sh
Executable file
12
travis/setup.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
psql -U postgres < setup.sql
|
||||
|
||||
sudo cp pg_hba.conf $(psql -U postgres -c "SHOW hba_file" -At)
|
||||
|
||||
DATA_DIR=$(psql -U postgres -c "SHOW data_directory" -At)
|
||||
PG_PID=$(sudo head -n1 $DATA_DIR/postmaster.pid)
|
||||
sudo kill -SIGHUP $PG_PID
|
4
travis/setup.sql
Normal file
4
travis/setup.sql
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE ROLE pass_user PASSWORD 'password' LOGIN;
|
||||
CREATE ROLE md5_user PASSWORD 'password' LOGIN;
|
||||
CREATE DATABASE pass_user OWNER pass_user;
|
||||
CREATE DATABASE md5_user OWNER md5_user;
|
Loading…
Reference in New Issue
Block a user