forked from dotenv-rs/dotenv
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement overriding API methods and correct inconsistent naming (
#47) * feat: Implement overriding api methods * fix: Use consistent naming
- Loading branch information
1 parent
639e9b1
commit 69a0623
Showing
12 changed files
with
253 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
mod common; | ||
|
||
use std::{env, error::Error, result::Result}; | ||
|
||
use dotenvy::*; | ||
|
||
use crate::common::*; | ||
|
||
#[test] | ||
fn test_default_location_override() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
dotenv_override()?; | ||
|
||
assert_eq!(env::var("TESTKEY")?, "test_val_overridden"); | ||
assert_eq!(env::var("EXISTING")?, "from_file"); | ||
|
||
env::set_current_dir(dir.path().parent().unwrap())?; | ||
dir.close()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
mod common; | ||
|
||
use dotenvy::*; | ||
use std::{env, error::Error, result::Result}; | ||
|
||
use crate::common::*; | ||
|
||
#[test] | ||
fn test_from_filename_override() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
from_filename_override(".env")?; | ||
|
||
assert_eq!(env::var("TESTKEY")?, "test_val_overridden"); | ||
assert_eq!(env::var("EXISTING")?, "from_file"); | ||
|
||
env::set_current_dir(dir.path().parent().unwrap())?; | ||
dir.close()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
mod common; | ||
|
||
use crate::common::*; | ||
use dotenvy::*; | ||
use std::{env, error::Error, result::Result}; | ||
|
||
#[test] | ||
fn test_from_path_override() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
let mut path = env::current_dir()?; | ||
path.push(".env"); | ||
|
||
from_path_override(&path)?; | ||
|
||
assert_eq!(env::var("TESTKEY")?, "test_val_overridden"); | ||
assert_eq!(env::var("EXISTING")?, "from_file"); | ||
|
||
env::set_current_dir(dir.path().parent().unwrap())?; | ||
dir.close()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
mod common; | ||
|
||
use dotenvy::*; | ||
use std::{env, error::Error, fs::File, result::Result}; | ||
|
||
use crate::common::*; | ||
|
||
#[test] | ||
fn test_from_read_override() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
from_read_override(File::open(".env")?)?; | ||
|
||
assert_eq!(env::var("TESTKEY")?, "test_val_overridden"); | ||
assert_eq!(env::var("EXISTING")?, "from_file"); | ||
|
||
env::set_current_dir(dir.path().parent().unwrap())?; | ||
dir.close()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
mod common; | ||
|
||
use dotenvy::*; | ||
use std::{env, error::Error, fs::File, result::Result}; | ||
|
||
use crate::common::*; | ||
|
||
#[test] | ||
fn test_from_read() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
from_read(File::open(".env")?)?; | ||
|
||
assert_eq!(env::var("TESTKEY")?, "test_val"); | ||
assert_eq!(env::var("EXISTING")?, "from_env"); | ||
|
||
env::set_current_dir(dir.path().parent().unwrap())?; | ||
dir.close()?; | ||
Ok(()) | ||
} |
Oops, something went wrong.