Compare commits
5 Commits
v0.5.0-27-
...
v0.3.4-20-
Author | SHA1 | Date | |
---|---|---|---|
1113e90e34
|
|||
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
|
||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -297,7 +297,7 @@ checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
|
||||
|
||||
[[package]]
|
||||
name = "icarus_envy"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"const_format",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "icarus_envy"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
edition = "2024"
|
||||
rust-version = "1.88"
|
||||
|
||||
|
@@ -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