Skip to content

Commit

Permalink
Merge tests into parameterized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
delsner committed Jun 5, 2024
1 parent 569bd07 commit 9997bce
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ struct Options {
#[fixture]
fn options(
#[default(PathBuf::from("examples/simple-python/pixi.toml"))] manifest_path: PathBuf,
#[default(false)] ignore_pypi_errors: bool,
#[default("default")] environment: String,
#[default(Platform::current())] platform: Platform,
#[default(None)] auth_file: Option<PathBuf>,
#[default(PixiPackMetadata::default())] metadata: PixiPackMetadata,
#[default(Some(Level::Best))] level: Option<Level>,
#[default(Some(ShellEnum::Bash(Bash)))] shell: Option<ShellEnum>,
#[default(false)] ignore_pypi_errors: bool,
) -> Options {
let output_dir = tempdir().expect("Couldn't create a temp dir for tests");
let pack_file = output_dir.path().join("environment.tar.zstd");
Expand Down Expand Up @@ -173,21 +173,16 @@ async fn test_compatibility(
}

#[rstest]
#[case(true, false)]
#[case(false, true)]
#[tokio::test]
async fn test_pypi_ignore(
#[with(PathBuf::from("examples/pypi-packages/pixi.toml"), true)] options: Options,
#[with(PathBuf::from("examples/pypi-packages/pixi.toml"))] options: Options,
#[case] ignore_pypi_errors: bool,
#[case] should_fail: bool,
) {
assert!(options.pack_options.ignore_pypi_errors);
let pack_result = pixi_pack::pack(options.pack_options).await;
assert!(pack_result.is_ok());
}

#[rstest]
#[tokio::test]
async fn test_pypi_fail(
#[with(PathBuf::from("examples/pypi-packages/pixi.toml"), false)] options: Options,
) {
assert!(!options.pack_options.ignore_pypi_errors);
let pack_result = pixi_pack::pack(options.pack_options).await;
assert!(pack_result.is_err());
let mut pack_options = options.pack_options;
pack_options.ignore_pypi_errors = ignore_pypi_errors;
let pack_result = pixi_pack::pack(pack_options).await;
assert_eq!(pack_result.is_err(), should_fail);
}

0 comments on commit 9997bce

Please sign in to comment.