Translate appearance and outfit parity tests
This commit is contained in:
@@ -29,6 +29,43 @@ pub fn block_on<F: Future>(future: F) -> F::Output {
|
||||
}
|
||||
}
|
||||
|
||||
/// Loads the live-grid identity from the process environment or workspace `.env`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics when one of `GRID_USER`, `GRID_PASSWORD`, or `GRID_LOGIN_URL` is absent.
|
||||
#[must_use]
|
||||
pub fn live_grid_credentials() -> (String, String, String, String) {
|
||||
fn credential(name: &str) -> String {
|
||||
if let Ok(value) = std::env::var(name)
|
||||
&& !value.trim().is_empty()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
let dotenv = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../..")
|
||||
.join(".env");
|
||||
let contents = std::fs::read_to_string(dotenv).expect("read workspace .env");
|
||||
contents
|
||||
.lines()
|
||||
.find_map(|line| {
|
||||
let line = line.trim().strip_prefix("export ").unwrap_or(line.trim());
|
||||
let (key, value) = line.split_once('=')?;
|
||||
(key.trim() == name).then(|| value.trim().trim_matches(['\'', '"']).to_owned())
|
||||
})
|
||||
.filter(|value| !value.is_empty())
|
||||
.unwrap_or_else(|| panic!("live test requires {name}"))
|
||||
}
|
||||
|
||||
let full_name = credential("GRID_USER");
|
||||
let password = credential("GRID_PASSWORD");
|
||||
let login_url = credential("GRID_LOGIN_URL");
|
||||
let mut names = full_name.split_whitespace();
|
||||
let first = names.next().expect("live first name").to_owned();
|
||||
let last = names.next().expect("live last name").to_owned();
|
||||
(first, last, password, login_url)
|
||||
}
|
||||
|
||||
/// Asserts equality within the exact absolute tolerance carried by an upstream test.
|
||||
///
|
||||
/// # Panics
|
||||
|
||||
Reference in New Issue
Block a user