Skip to content

Commit

Permalink
fix: make tests more deterministic and use single * for glob expansion (
Browse files Browse the repository at this point in the history
prefix-dev#987)

Co-authored-by: Bas Zalmstra <[email protected]>
  • Loading branch information
wolfv and baszalmstra committed Mar 15, 2024
1 parent 1b71b5f commit 7a535bd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lock_file/satisfiability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ mod tests {
use rstest::rstest;
use std::path::PathBuf;

#[derive(Error, Debug)]
#[derive(Error, Debug, Diagnostic)]
enum LockfileUnsat {
#[error("environment '{0}' is missing")]
EnvironmentMissing(String),
Expand Down Expand Up @@ -497,7 +497,7 @@ mod tests {

#[rstest]
fn test_good_satisfiability(
#[files("tests/satisfiability/**/pixi.toml")] manifest_path: PathBuf,
#[files("tests/satisfiability/*/pixi.toml")] manifest_path: PathBuf,
) {
let project = Project::load(&manifest_path).unwrap();
let lock_file = LockFile::from_path(&project.lock_file_path()).unwrap();
Expand All @@ -508,7 +508,7 @@ mod tests {
}

#[rstest]
fn test_example_satisfiability(#[files("examples/**/pixi.toml")] manifest_path: PathBuf) {
fn test_example_satisfiability(#[files("examples/*/pixi.toml")] manifest_path: PathBuf) {
let project = Project::load(&manifest_path).unwrap();
let lock_file = LockFile::from_path(&project.lock_file_path()).unwrap();
match verify_lockfile_satisfiability(&project, &lock_file).into_diagnostic() {
Expand All @@ -519,17 +519,17 @@ mod tests {

#[test]
fn test_failing_satisiability() {
let _handler = miette::set_hook(Box::new(|_| {
Box::new(NarratableReportHandler::new().with_cause_chain())
}));
let report_handler = NarratableReportHandler::new().with_cause_chain();

insta::glob!("../../tests/non-satisfiability", "**/pixi.toml", |path| {
insta::glob!("../../tests/non-satisfiability", "*/pixi.toml", |path| {
let project = Project::load(&path).unwrap();
let lock_file = LockFile::from_path(&project.lock_file_path()).unwrap();
let err = verify_lockfile_satisfiability(&project, &lock_file)
.into_diagnostic()
.expect_err("expected failing satisfiability");
insta::assert_snapshot!(format!("{err:?}"));

let mut s = String::new();
report_handler.render_report(&mut s, &err).unwrap();
insta::assert_snapshot!(s);
});
}
}

0 comments on commit 7a535bd

Please sign in to comment.