Compare commits

...

4 Commits

Author SHA1 Message Date
2216f27df1 Code formatting
All checks were successful
Release Tagging / release (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 37s
Rust Build / Check (pull_request) Successful in 52s
Rust Build / Test Suite (pull_request) Successful in 1m6s
Rust Build / Clippy (pull_request) Successful in 36s
Rust Build / build (pull_request) Successful in 40s
2025-09-29 15:16:36 -04:00
fa4ee845c5 Added test 2025-09-29 15:16:12 -04:00
8a55df3e14 Added env variables 2025-09-29 15:15:45 -04:00
a8ec7cae78 Added general environment function
All checks were successful
Rust Build / build (pull_request) Successful in 32s
Release Tagging / release (pull_request) Successful in 39s
Rust Build / Check (pull_request) Successful in 32s
Rust Build / Test Suite (pull_request) Successful in 36s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 41s
2025-09-28 19:20:34 -04:00
4 changed files with 30 additions and 0 deletions

2
.env
View File

@@ -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_MAIN_KEY=Somesupersecretpassword!!!45345435
SECRET_KEY=AmIGoodEnoughForYou? SECRET_KEY=AmIGoodEnoughForYou?
SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO

View File

@@ -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_MAIN_KEY=Somesupersecretpassword!!!45345435
SECRET_KEY=AmIGoodEnoughForYou? SECRET_KEY=AmIGoodEnoughForYou?
SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO

View File

@@ -58,3 +58,10 @@ pub async fn get_allowed_origins() -> String {
dotenvy::dotenv().ok(); dotenvy::dotenv().ok();
std::env::var(crate::keys::ALLOWED_ORIGINS).expect(crate::keys::error::ALLOWED_ORIGINS) 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)
}

View File

@@ -59,4 +59,23 @@ mod tests {
result 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)
}
}
} }