Skip to content

Commit

Permalink
Change fixture to return tempdir
Browse files Browse the repository at this point in the history
  • Loading branch information
delsner committed Jun 3, 2024
1 parent d37e4bb commit bf32654
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ use pixi_pack::{PackOptions, PixiPackMetadata, UnpackOptions};
use rattler_conda_types::Platform;
use rattler_shell::shell::{Bash, ShellEnum};
use rstest::*;
use tempfile::tempdir;
use tempfile::{tempdir, TempDir};

struct Options(PackOptions, UnpackOptions);
struct Options {
pack_options: PackOptions,
unpack_options: UnpackOptions,
output_dir: TempDir,
}

#[fixture]
fn options(
Expand All @@ -21,8 +25,8 @@ fn options(
) -> Options {
let output_dir = tempdir().expect("Couldn't create a temp dir for tests");
let pack_file = output_dir.path().join("environment.tar.zstd");
Options(
PackOptions {
Options {
pack_options: PackOptions {
environment,
platform,
auth_file,
Expand All @@ -31,24 +35,22 @@ fn options(
metadata,
level,
},
UnpackOptions {
unpack_options: UnpackOptions {
pack_file,
output_directory: output_dir.path().to_path_buf(),
shell,
},
)
output_dir,
}
}

#[rstest]
#[tokio::test]
async fn test_simple_python(options: Options) {
let mut pack_options = options.0;
let mut unpack_options = options.1;
let temp_dir = tempdir().expect("Couldn't create a temp dir for tests");
let pack_file = temp_dir.path().join("environment.tar.zstd");
pack_options.output_file = pack_file.clone();
unpack_options.pack_file = pack_file.clone();
unpack_options.output_directory = temp_dir.path().to_path_buf();
let pack_options = options.pack_options;
let unpack_options = options.unpack_options;
let _output_dir = options.output_dir;
let pack_file = unpack_options.pack_file.clone();

let pack_result = pixi_pack::pack(pack_options).await;
assert!(pack_result.is_ok());
Expand Down

0 comments on commit bf32654

Please sign in to comment.