Skip to content

Commit

Permalink
Remove dotenvy from test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
sonro committed Aug 1, 2024
1 parent 9aa6b27 commit afb2ea9
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 48 deletions.
3 changes: 0 additions & 3 deletions test_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ rust-version = "1.68.0"
[dependencies]
tempfile = "3.3.0"
once_cell = "1.16.0"

[dev-dependencies]
dotenvy = { path = "../dotenv", version = "0.15.7" }
2 changes: 1 addition & 1 deletion test_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//!
//! ## Example
//!
//! ```no_run
//! ```rust,ignore
//! use dotenvy_test_util::*;
//! use dotenvy::dotenv_override;
//!
Expand Down
2 changes: 0 additions & 2 deletions test_util/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const CUSTOM_VARS: &[(&str, &str)] = &[
("CUSTOM_KEY_2", "CUSTOM_VALUE_2"),
];

const DOTENV_EXPECT: &str = "TestEnv should have .env file";

fn test_env_files(testenv: &TestEnv) -> Result<(), Error> {
let files = testenv.env_files();

Expand Down
42 changes: 0 additions & 42 deletions test_util/src/tests/testenv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::*;
use dotenvy::dotenv;

mod new {
use std::collections::HashMap;
Expand Down Expand Up @@ -28,7 +27,6 @@ mod new {

test_in_env(&testenv, || {
assert!(!env_file_path.exists());
assert!(dotenv().is_err());
})
}

Expand Down Expand Up @@ -69,18 +67,6 @@ mod new_with_env_file {
test_env_files(&testenv)
}

#[test]
fn env_file_loaded_vars_state() -> Result<(), Error> {
let testenv = testenv_with_test_env_file()?;
test_in_env(&testenv, || {
dotenv().expect(DOTENV_EXPECT);
// dotenv() does not override existing var
// but existing key is not set in this testenv
assert_env_var(EXISTING_KEY, OVERRIDING_VALUE);
assert_env_var(TEST_KEY, TEST_VALUE);
})
}

#[test]
fn custom_env_file_vars_state() -> Result<(), Error> {
let testenv = testenv_with_custom_env_file()?;
Expand All @@ -98,46 +84,18 @@ mod new_with_env_file {
test_env_files(&testenv)
}

#[test]
fn custom_env_file_loaded_vars_state() -> Result<(), Error> {
let testenv = testenv_with_custom_env_file()?;
test_in_env(&testenv, || {
dotenv().expect(DOTENV_EXPECT);
assert_test_keys_unset();
assert_env_vars(CUSTOM_VARS);
})
}

#[test]
fn empty_env_file_exists() -> Result<(), Error> {
let testenv = testenv_with_empty_env_file()?;
test_env_files(&testenv)
}

#[test]
fn empty_env_file_loaded_vars_state() -> Result<(), Error> {
let testenv = testenv_with_empty_env_file()?;
test_in_env(&testenv, || {
dotenv().expect(DOTENV_EXPECT);
assert_test_keys_unset();
})
}

#[test]
fn custom_bom_env_file_exists() -> Result<(), Error> {
let testenv = testenv_with_custom_bom_env_file()?;
test_env_files(&testenv)
}

#[test]
fn custom_bom_env_file_loaded_vars_state() -> Result<(), Error> {
let testenv = testenv_with_custom_bom_env_file()?;
test_in_env(&testenv, || {
dotenv().expect(DOTENV_EXPECT);
assert_env_var(TEST_KEY, TEST_VALUE);
})
}

fn testenv_with_test_env_file() -> Result<TestEnv, Error> {
let env_file = create_test_env_file();
TestEnv::new_with_env_file(env_file)
Expand Down

0 comments on commit afb2ea9

Please sign in to comment.