Skip to content

Commit

Permalink
Update crates/rattler_repodata_gateway/src/sparse/mod.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Bas Zalmstra <zalmstra.bas@gmail.com>
  • Loading branch information
ruben-arts and baszalmstra authored Oct 21, 2023
1 parent 97b6ef5 commit 4b9f34a
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions crates/rattler_repodata_gateway/src/sparse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,25 +460,38 @@ mod test {

#[tokio::test]
async fn test_sparse_strict() {
let strict_sparse_data = load_sparse(["pytorch-cpu"], true).await;
let total_records = strict_sparse_data
.iter()
.filter(|repo| {
repo.into_iter()
.any(|package| package.file_name.contains("pytorch-cpu"))
})
.count();
assert_eq!(total_records, 1);

// If we load pytorch-cpy from all channels (non-strict) we expect records from both
// conda-forge and pthe pytorch channels.
let sparse_data = load_sparse(["pytorch-cpu"], false).await;
let total_records = sparse_data
.iter()
.filter(|repo| {
repo.into_iter()
.any(|package| package.file_name.contains("pytorch-cpu"))
})
.count();
assert_eq!(total_records, 2);
let channels = sparse_data
.into_iter()
.flatten()
.filter(|record| record.package_record.name.as_normalized() == "pytorch-cpu")
.map(|record| record.channel)
.unique()

Check failure on line 471 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / Linux-x86_64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 471 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / Linux-aarch64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 471 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / macOS-x86_64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 471 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / macOS-aarch64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 471 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / Windows-x86_64

no method named `unique` found for struct `Map` in the current scope
.collect_vec();
assert_eq!(
channels,
vec![
String::from("https://conda.anaconda.org/conda-forge/"),
String::from("https://conda.anaconda.org/pytorch/")
]
);

// If we load pytorch-cpy from strict channels we expect records only from the first channel
// that contains the package. In this case we expect records only from conda-forge.
let strict_sparse_data = load_sparse(["pytorch-cpu"], true).await;
let channels = strict_sparse_data
.into_iter()
.flatten()
.filter(|record| record.package_record.name.as_normalized() == "pytorch-cpu")
.map(|record| record.channel)
.unique()

Check failure on line 489 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / Linux-x86_64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 489 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / Linux-aarch64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 489 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / macOS-x86_64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 489 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / macOS-aarch64

no method named `unique` found for struct `Map` in the current scope

Check failure on line 489 in crates/rattler_repodata_gateway/src/sparse/mod.rs

View workflow job for this annotation

GitHub Actions / Windows-x86_64

no method named `unique` found for struct `Map` in the current scope
.collect_vec();
assert_eq!(
channels,
vec![String::from("https://conda.anaconda.org/conda-forge/")]
);
}

#[tokio::test]
Expand Down

0 comments on commit 4b9f34a

Please sign in to comment.