Skip to content

Commit

Permalink
add a test for Collection::intersect_manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Sep 17, 2024
1 parent b7a9850 commit 9c26752
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/core/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ mod test {
use crate::selection::Selection;
use crate::signature::Signature;
use crate::Result;

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (windows)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (macos)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (windows)

unused import: `crate::Result`

Check warning on line 247 in src/core/src/collection.rs

View workflow job for this annotation

GitHub Actions / test (macos)

unused import: `crate::Result`
use crate::manifest::Manifest;

#[test]
fn sigstore_selection_with_downsample() {
Expand Down Expand Up @@ -366,6 +367,33 @@ mod test {
assert_eq!(cl.len(), 0);
}

#[test]
fn collection_intersect_manifest() {
// load test sigs
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// four num=500 sigs
filename.push("../../tests/test-data/genome-s11.fa.gz.sig");
let file = File::open(filename).unwrap();
let reader = BufReader::new(file);
let sigs: Vec<Signature> = serde_json::from_reader(reader).expect("Loading error");
assert_eq!(sigs.len(), 4);
// load sigs into collection + select compatible signatures
let cl = Collection::from_sigs(sigs)
.unwrap();
// all sigs should remain
assert_eq!(cl.len(), 4);

// grab first record
let manifest = cl.manifest();
let record = manifest.iter().next().unwrap().clone();
let vr = vec![record];

// now intersect:
let manifest2 = Manifest::from(vr);
let cl2 = cl.intersect_manifest(&manifest2);
assert_eq!(cl2.len(), 1);
}

#[test]
fn sigstore_sig_from_record() {
// load test sigs
Expand Down

0 comments on commit 9c26752

Please sign in to comment.