Skip to content

Commit

Permalink
test: more readable error
Browse files Browse the repository at this point in the history
Let's you know which variable is missing

CMK-20046
  • Loading branch information
SoloJacobs committed Nov 11, 2024
1 parent 39ddb18 commit 6ec3b7c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 9 additions & 0 deletions tests/helper.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
use anyhow::Context;
use camino::Utf8PathBuf;
use robotmk::config::Config;
use robotmk::results::{plan_results_directory, results_directory};
use std::ffi::OsStr;
use std::path::Path;
use std::time::Duration;
use tokio::time::sleep;
use walkdir::WalkDir;

pub fn var<K: AsRef<OsStr>>(key: K) -> anyhow::Result<String> {
std::env::var(key.as_ref()).context(format!(
"Could not read: {}",
key.as_ref().to_string_lossy()
))
}

pub async fn await_plan_results(config: &Config) {
let expected_result_files: Vec<Utf8PathBuf> = config
.plan_groups
Expand Down
3 changes: 1 addition & 2 deletions tests/test_ht_import_scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(unix)]
pub mod helper;
use crate::helper::{await_plan_results, directory_entries};
use crate::helper::{await_plan_results, directory_entries, var};
use anyhow::{bail, Result as AnyhowResult};
use assert_cmd::cargo::cargo_bin;
use camino::{Utf8Path, Utf8PathBuf};
Expand All @@ -12,7 +12,6 @@ use robotmk::config::{
use robotmk::results::results_directory;
use robotmk::section::Host;
use serde_json::to_string;
use std::env::var;
use std::fs::{create_dir_all, remove_file, write};
use std::time::Duration;
use tokio::{
Expand Down
3 changes: 1 addition & 2 deletions tests/test_scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod helper;
pub mod rcc;
use crate::helper::{await_plan_results, directory_entries};
use crate::helper::{await_plan_results, directory_entries, var};
use crate::rcc::read_configuration_diagnostics;
use anyhow::{bail, Result as AnyhowResult};
use assert_cmd::cargo::cargo_bin;
Expand All @@ -15,7 +15,6 @@ use robotmk::config::{
use robotmk::results::results_directory;
use robotmk::section::Host;
use serde_json::to_string;
use std::env::var;
#[cfg(windows)]
use std::ffi::OsStr;
use std::fs::{create_dir_all, remove_file, write};
Expand Down

0 comments on commit 6ec3b7c

Please sign in to comment.