Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dotenv for testing #7

Merged
merged 1 commit into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgresql://localhost/yaqb_test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
Cargo.lock
.env
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ byteorder = "0.3.*"
[dev-dependencies]
compiletest_rs = "*"
quickcheck = "*"
dotenv = "0.4.0"

[[test]]
name = "compile_tests"
Expand Down
2 changes: 2 additions & 0 deletions src/expression/extensions/interval_dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl DayAndMonthIntervalDsl for f64 {

#[cfg(test)]
mod tests {
extern crate dotenv;
extern crate quickcheck;
use self::quickcheck::quickcheck;
use super::*;
Expand All @@ -121,6 +122,7 @@ mod tests {
macro_rules! test_fn {
($tpe:ty, $test_name:ident, $units:ident) => {
fn $test_name(val: $tpe) -> bool {
dotenv::dotenv().ok();
let connection_url = ::std::env::var("DATABASE_URL").ok()
.expect("DATABASE_URL must be set in order to run tests");
let connection = Connection::establish(&connection_url).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions tests/schema.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use yaqb::*;
extern crate dotenv;

#[derive(PartialEq, Eq, Debug, Clone)]
pub struct User {
Expand Down Expand Up @@ -170,6 +171,7 @@ pub fn connection() -> Connection {
}

pub fn connection_without_transaction() -> Connection {
dotenv::dotenv().ok();
let connection_url = ::std::env::var("DATABASE_URL").ok()
.expect("DATABASE_URL must be set in order to run tests");
Connection::establish(&connection_url).unwrap()
Expand Down