Skip to content

Commit

Permalink
add test for repodata patches
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbe7a committed Jun 5, 2024
1 parent 8876318 commit 2373483
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum Commands {
platform: Platform,

/// Authentication file for fetching packages
#[arg(short, long)] // TODO: Read from environment variable?
#[arg(long)] // TODO: Read from environment variable?
auth_file: Option<PathBuf>,

/// The path to 'pixi.toml' or 'pyproject.toml'
Expand All @@ -53,9 +53,9 @@ enum Commands {
#[arg(short, long, default_value = cwd().join("environment.tar.zstd").into_os_string())]
output_file: PathBuf,

/// Inject a additional conda package into the final prefix
/// Inject an additional conda package into the final prefix
#[arg(short, long, num_args(0..))]
additional_packages: Vec<PathBuf>,
inject: Vec<PathBuf>,

/// PyPI dependencies are not supported.
/// This flag allows packing even if PyPI dependencies are present.
Expand Down Expand Up @@ -101,7 +101,7 @@ async fn main() -> Result<()> {
auth_file,
manifest_path,
output_file,
additional_packages,
inject,
ignore_pypi_errors,
} => {
let options = PackOptions {
Expand All @@ -115,7 +115,7 @@ async fn main() -> Result<()> {
platform,
},
level: None,
additional_packages,
additional_packages: inject,
ignore_pypi_errors,
};
tracing::debug!("Running pack command with options: {:?}", options);
Expand Down
38 changes: 38 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ use std::{path::PathBuf, process::Command};
use async_compression::Level;
use pixi_pack::{unarchive, PackOptions, PixiPackMetadata, UnpackOptions};
use rattler_conda_types::Platform;
use rattler_conda_types::RepoData;
use rattler_shell::shell::{Bash, ShellEnum};
use rstest::*;
use tempfile::{tempdir, TempDir};
use tokio::fs::File;
use tokio::io::AsyncReadExt;

struct Options {
pack_options: PackOptions,
Expand Down Expand Up @@ -137,6 +140,41 @@ async fn test_inject(options: Options, mut required_fs_objects: Vec<&'static str
});
}

#[rstest]
#[tokio::test]
async fn test_includes_repodata_patches(options: Options) {
let pack_options = options.pack_options;
let pack_file = options.unpack_options.pack_file.clone();

let pack_result = pixi_pack::pack(pack_options).await;
println!("{:?}", pack_result);
assert!(pack_result.is_ok());

let unpack_dir = tempdir().expect("Couldn't create a temp dir for tests");
let unpack_dir = unpack_dir.path();
unarchive(pack_file.as_path(), unpack_dir)
.await
.expect("Failed to unarchive environment");

let mut repodata_raw = String::new();

File::open(unpack_dir.join("win-64/repodata.json"))
.await
.expect("Failed to open repodata")
.read_to_string(&mut repodata_raw)
.await
.expect("could not read repodata.json");

let repodata: RepoData = serde_json::from_str(&repodata_raw).expect("cant parse repodata.json");

assert!(repodata
.conda_packages
.get("python")
.expect("python not found in repodata")
.depends
.contains(&"libzlib <2".to_string()))
}

#[cfg(not(target_os = "windows"))] // https://github.com/Quantco/pixi-pack/issues/8
#[rstest]
#[case("conda")]
Expand Down

0 comments on commit 2373483

Please sign in to comment.