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
- Loading branch information
1 parent
0afdc92
commit 6a40db6
Showing
12 changed files
with
247 additions
and
31 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_overload() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
overload()?; | ||
|
||
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_overload() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
from_filename_overload(".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_overload() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
let mut path = env::current_dir()?; | ||
path.push(".env"); | ||
|
||
from_path_overload(&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_overload() -> Result<(), Box<dyn Error>> { | ||
let dir = make_test_dotenv()?; | ||
|
||
from_read_overload(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(()) | ||
} |
This file was deleted.
Oops, something went wrong.