Skip to content

Commit

Permalink
Add a test for declared environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored and la10736 committed Sep 26, 2024
1 parent c65d1c0 commit a970613
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rstest/tests/resources/rstest/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ fn ignore_missing_env_vars(
let _ = path;
}

#[rstest]
fn env_vars(
#[files("${FILES_ENV_VAR}/**/*.txt")]
#[exclude("exclude")]
path: PathBuf,
) {
let _ = path;
}

mod module {
#[rstest::rstest]
fn pathbuf_need_not_be_in_scope(
Expand Down
7 changes: 7 additions & 0 deletions rstest/tests/rstest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ fn run_test(res: impl AsRef<Path>) -> (std::process::Output, String) {

#[test]
fn files() {
std::env::set_var("FILES_ENV_VAR", "files");

let prj = prj("files.rs");
let files_path = prj.path().join("files");
let sub_folder = files_path.join("sub");
Expand Down Expand Up @@ -62,6 +64,11 @@ fn files() {
let output = prj.run_tests().unwrap();

TestResults::new()
.ok("env_vars::path_1_files_element_0_txt")
.ok("env_vars::path_2_files_element_1_txt")
.ok("env_vars::path_3_files_element_2_txt")
.ok("env_vars::path_4_files_element_3_txt")
.ok("env_vars::path_5_files_sub_sub_dir_file_txt")
.ok("ignore_missing_env_vars::path_1_files_element_0_txt")
.ok("ignore_missing_env_vars::path_2_files_element_1_txt")
.ok("ignore_missing_env_vars::path_4_files_element_3_txt")
Expand Down

0 comments on commit a970613

Please sign in to comment.