Compare commits
4 Commits
v0.3.4-mai
...
v0.3.3-20-
Author | SHA1 | Date | |
---|---|---|---|
2216f27df1
|
|||
fa4ee845c5
|
|||
8a55df3e14
|
|||
a8ec7cae78
|
2
.env
2
.env
@@ -1,3 +1,5 @@
|
||||
RANDOM_ENV_KEY="YouDon'tWantToButYouGottaChange|It'sGoingToHurtYouTryingToStayTheSame|AreYouInItOrYouInItForTheFame?|I'mTryingToFigureOutWhoLoveMeForMe"
|
||||
MODNAR_ENV_KEY="FeelingTheMonsterClimbDeepserInsideOfMe|FeelingHimGnawingMyHeartAwayHungrily|I'llNeverLoseThisPain|NeverDreamOfYouAgain"
|
||||
SECRET_MAIN_KEY=Somesupersecretpassword!!!45345435
|
||||
SECRET_KEY=AmIGoodEnoughForYou?
|
||||
SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO
|
||||
|
@@ -1,3 +1,5 @@
|
||||
RANDOM_ENV_KEY="YouDon'tWantToButYouGottaChange|It'sGoingToHurtYouTryingToStayTheSame|AreYouInItOrYouInItForTheFame?|I'mTryingToFigureOutWhoLoveMeForMe"
|
||||
MODNAR_ENV_KEY="FeelingTheMonsterClimbDeepserInsideOfMe|FeelingHimGnawingMyHeartAwayHungrily|I'llNeverLoseThisPain|NeverDreamOfYouAgain"
|
||||
SECRET_MAIN_KEY=Somesupersecretpassword!!!45345435
|
||||
SECRET_KEY=AmIGoodEnoughForYou?
|
||||
SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO
|
||||
|
@@ -58,3 +58,10 @@ pub async fn get_allowed_origins() -> String {
|
||||
dotenvy::dotenv().ok();
|
||||
std::env::var(crate::keys::ALLOWED_ORIGINS).expect(crate::keys::error::ALLOWED_ORIGINS)
|
||||
}
|
||||
|
||||
/// Get environment not specified in the code
|
||||
pub async fn get_env(environment: &str) -> String {
|
||||
dotenvy::dotenv().ok();
|
||||
let my_error = format!("{environment} {}", crate::keys::error::GENERAL_ERROR);
|
||||
std::env::var(environment).expect(&my_error)
|
||||
}
|
||||
|
@@ -59,4 +59,23 @@ mod tests {
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_env() {
|
||||
let keys = vec![
|
||||
(
|
||||
"RANDOM_ENV_KEY",
|
||||
"YouDon'tWantToButYouGottaChange|It'sGoingToHurtYouTryingToStayTheSame|AreYouInItOrYouInItForTheFame?|I'mTryingToFigureOutWhoLoveMeForMe",
|
||||
),
|
||||
(
|
||||
"MODNAR_ENV_KEY",
|
||||
"FeelingTheMonsterClimbDeepserInsideOfMe|FeelingHimGnawingMyHeartAwayHungrily|I'llNeverLoseThisPain|NeverDreamOfYouAgain",
|
||||
),
|
||||
];
|
||||
|
||||
for (key, value) in keys.iter() {
|
||||
let result = async_std::task::block_on(icarus_envy::environment::get_env(key));
|
||||
assert_eq!(result, *value, "{:?} does not match {:?}", key, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user