From 569bd07e915e77e34fe9764c99dedc75b3591b1e Mon Sep 17 00:00:00 2001 From: Daniel Elsner Date: Wed, 5 Jun 2024 16:37:58 +0200 Subject: [PATCH] Fix test --- src/pack.rs | 4 ++-- tests/integration_test.rs | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/pack.rs b/src/pack.rs index 954f9b9..917b83f 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -74,10 +74,10 @@ pub async fn pack(options: PackOptions) -> Result<()> { Package::Pypi(_) => { if options.ignore_pypi_errors { tracing::warn!( - "ignoring pypi package since pypi packages are not supported by pixi-pack" + "ignoring PyPI package since PyPI packages are not supported by pixi-pack" ); } else { - anyhow::bail!("pypi packages are not supported in pixi-pack"); + anyhow::bail!("PyPI packages are not supported in pixi-pack"); } } } diff --git a/tests/integration_test.rs b/tests/integration_test.rs index dcaec8c..6bfe78a 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -18,14 +18,14 @@ 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, - #[default(PathBuf::from("examples/simple-python/pixi.toml"))] manifest_path: PathBuf, #[default(PixiPackMetadata::default())] metadata: PixiPackMetadata, #[default(Some(Level::Best))] level: Option, #[default(Some(ShellEnum::Bash(Bash)))] shell: Option, - #[default(true)] 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"); @@ -173,17 +173,21 @@ async fn test_compatibility( } #[rstest] -#[case(true, false)] -#[case(false, true)] #[tokio::test] async fn test_pypi_ignore( - options: Options, - #[case] ignore_pypi_errors: bool, - #[case] should_fail: bool, + #[with(PathBuf::from("examples/pypi-packages/pixi.toml"), true)] options: Options, ) { - let mut pack_options = options.pack_options; - pack_options.ignore_pypi_errors = ignore_pypi_errors; + assert!(options.pack_options.ignore_pypi_errors); + let pack_result = pixi_pack::pack(options.pack_options).await; + assert!(pack_result.is_ok()); +} - let pack_result = pixi_pack::pack(pack_options).await; - assert_eq!(pack_result.is_err(), should_fail); +#[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()); }