Skip to content

Commit 4917b34

Browse files
committed
test(connector): Add issue to move env variable to config file
1 parent 8c3f361 commit 4917b34

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

crates/router/tests/connectors/selenium.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ pub trait SeleniumTest {
128128
Trigger::Goto(url) => {
129129
driver.goto(url).await?;
130130
let hs_base_url =
131-
env::var("HS_BASE_URL").unwrap_or("http://localhost:8080".to_string());
131+
env::var("HS_BASE_URL").unwrap_or("http://localhost:8080".to_string()); //Issue: #924
132132
let hs_api_key =
133-
env::var("HS_API_KEY").expect("Hyperswitch user API key not present");
133+
env::var("HS_API_KEY").expect("Hyperswitch user API key not present"); //Issue: #924
134134
driver
135135
.add_cookie(new_cookie("hs_base_url", hs_base_url).clone())
136136
.await?;
@@ -209,7 +209,7 @@ pub trait SeleniumTest {
209209
F: FnOnce(WebDriver) -> Fut + Send,
210210
Fut: Future<Output = Result<(), WebDriverError>> + Send,
211211
{
212-
let _browser = env::var("HS_TEST_BROWSER").unwrap_or("chrome".to_string());
212+
let _browser = env::var("HS_TEST_BROWSER").unwrap_or("chrome".to_string()); //Issue: #924
213213
Ok(())
214214
}
215215
async fn make_redirection_payment(
@@ -321,13 +321,13 @@ fn new_cookie(name: &str, value: String) -> Cookie<'_> {
321321

322322
#[macro_export]
323323
macro_rules! tester_inner {
324-
($f:ident, $connector:expr) => {{
324+
($execute:ident, $webdriver:expr) => {{
325325
use std::{
326326
sync::{Arc, Mutex},
327327
thread,
328328
};
329329

330-
let c = $connector;
330+
let driver = $webdriver;
331331

332332
// we'll need the session_id from the thread
333333
// NOTE: even if it panics, so can't just return it
@@ -336,20 +336,22 @@ macro_rules! tester_inner {
336336
// run test in its own thread to catch panics
337337
let sid = session_id.clone();
338338
let res = thread::spawn(move || {
339-
let rt = tokio::runtime::Builder::new_current_thread()
339+
let runtime = tokio::runtime::Builder::new_current_thread()
340340
.enable_all()
341341
.build()
342342
.unwrap();
343-
let c = rt.block_on(c).expect("failed to construct test WebDriver");
344-
*sid.lock().unwrap() = rt.block_on(c.session_id()).ok();
343+
let driver = runtime
344+
.block_on(driver)
345+
.expect("failed to construct test WebDriver");
346+
*sid.lock().unwrap() = runtime.block_on(driver.session_id()).ok();
345347
// make sure we close, even if an assertion fails
346-
let client = c.clone();
347-
let x = rt.block_on(async move {
348-
let r = tokio::spawn($f(c)).await;
348+
let client = driver.clone();
349+
let x = runtime.block_on(async move {
350+
let r = tokio::spawn($execute(driver)).await;
349351
let _ = client.quit().await;
350352
r
351353
});
352-
drop(rt);
354+
drop(runtime);
353355
x.expect("test panicked")
354356
})
355357
.join();
@@ -395,6 +397,7 @@ pub fn make_capabilities(s: &str) -> Capabilities {
395397
}
396398
fn get_chrome_profile_path() -> Result<String, WebDriverError> {
397399
env::var("CHROME_PROFILE_PATH").map_or_else(
400+
//Issue: #924
398401
|_| -> Result<String, WebDriverError> {
399402
let exe = env::current_exe()?;
400403
let dir = exe.parent().expect("Executable must be in some directory");
@@ -414,6 +417,7 @@ fn get_chrome_profile_path() -> Result<String, WebDriverError> {
414417
}
415418
fn get_firefox_profile_path() -> Result<String, WebDriverError> {
416419
env::var("FIREFOX_PROFILE_PATH").map_or_else(
420+
//Issue: #924
417421
|_| -> Result<String, WebDriverError> {
418422
let exe = env::current_exe()?;
419423
let dir = exe.parent().expect("Executable must be in some directory");
@@ -461,5 +465,5 @@ pub fn handle_test_error(
461465
}
462466

463467
pub fn get_env(name: &str) -> String {
464-
env::var(name).unwrap_or_else(|_| panic!("{name} not present"))
468+
env::var(name).unwrap_or_else(|_| panic!("{name} not present")) //Issue: #924
465469
}

0 commit comments

Comments
 (0)