Skip to content

Commit

Permalink
Make database URL tests work in parallel.
Browse files Browse the repository at this point in the history
There was a collision on the name of the environment variable "foo"
between two tests. One would set it (extract_database_url_returns_env_vars) and other (extract_database_url_errors_if_env_var_is_unset) would unset it.
As Cargo runs tests in parallel this would lead to this set of test
having intermittent failures.

Changed the names of the environment variables used in the tests to make
them unique between tests, hence able to run in parallel.
  • Loading branch information
cyplo committed Oct 12, 2016
1 parent df5be0a commit 50eea4d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions diesel_codegen_shared/src/database_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ fn extract_database_url_returns_the_given_string() {

#[test]
fn extract_database_url_returns_env_vars() {
env::set_var("foo", "lololol");
env::set_var("bar", "trolololol");
assert_eq!("lololol", extract_database_url("env:foo").unwrap());
assert_eq!("trolololol", extract_database_url("env:bar").unwrap());
env::set_var("lolvar", "lololol");
env::set_var("trolvar", "trolololol");
assert_eq!("lololol", extract_database_url("env:lolvar").unwrap());
assert_eq!("trolololol", extract_database_url("env:trolvar").unwrap());
}

#[test]
fn extract_database_url_errors_if_env_var_is_unset() {
env::remove_var("foo");
assert!(extract_database_url("env:foo").is_err());
env::remove_var("selfdestructvar");
assert!(extract_database_url("env:selfdestructvar").is_err());
}

0 comments on commit 50eea4d

Please sign in to comment.