Skip to content

Commit

Permalink
failing tests for postgres ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Mar 3, 2019
1 parent 550478a commit 1677445
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ test-pq:
./test.sh pq
test-dieselpg:
./test.sh dieselpg
test-dieselpgssl:
./test.sh dieselpgssl
test-dieselsqlite:
./test.sh dieselsqlite
test-ssl:
Expand Down
12 changes: 12 additions & 0 deletions test/dieselpgsslcrate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
authors = ["clux <[email protected]>"]
name = "dieselpgsslcrate"
version = "0.1.0"
edition = "2018"

[dependencies]
log = "0.4.*"
env_logger = "0.6"
uuid = { version = "0.7.*", features = ["v4"] }
diesel = { version = "1.4.*", features = ["postgres", "uuid", "r2d2"] }
openssl = "*"
15 changes: 15 additions & 0 deletions test/dieselpgsslcrate/src/db.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use diesel::pg::PgConnection;
use diesel::r2d2::{ConnectionManager, Pool};
use std::sync::Arc;

pub(crate) type ConnectionPool = Arc<Pool<ConnectionManager<PgConnection>>>;

pub(crate) fn create_database_pool(url: &str, size: u32) -> ConnectionPool {
let manager = ConnectionManager::<PgConnection>::new(url);
let pool = Pool::builder()
.max_size(size)
.build(manager)
.expect("Error creating a database pool");

Arc::new(pool)
}
27 changes: 27 additions & 0 deletions test/dieselpgsslcrate/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#[macro_use] extern crate diesel;
extern crate openssl;
use std::env;

fn main() {
env_logger::init();

let _db = {
let url = std::env::var("DATABASE_URL")
.unwrap_or("postgres://localhost?connect_timeout=1&sslmode=require".into());
let size = env::var("DATABASE_POOL_SIZE")
.map(|val| {
val.parse::<u32>()
.expect("Error converting DATABASE_POOL_SIZE variable into u32")
})
.unwrap_or_else(|_| 5);

crate::db::create_database_pool(&url, size)
};

{
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
}
}

pub(crate) mod db;
6 changes: 6 additions & 0 deletions test/dieselpgsslcrate/src/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
table! {
room (id) {
id -> Uuid,
data -> Text,
}
}

0 comments on commit 1677445

Please sign in to comment.