Skip to content

Commit

Permalink
tests: check entire BarcodeCount structs instead of members, more def…
Browse files Browse the repository at this point in the history
…ensive
  • Loading branch information
theJasonFan committed Mar 1, 2024
1 parent 0e7b682 commit 0588ccd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ impl<'a> SampleBarcodeHopTracker<'a> {
}

/// A helper struct fot serializing and deserializing barcode counts.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub(crate) struct BarcodeCount {
/// The barcode.
pub(crate) barcode: String,
Expand Down
8 changes: 3 additions & 5 deletions src/lib/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,17 +1442,15 @@ s2,CCC,AAA"#;
let delim = DelimFile::default();
let hop_metrics: Vec<BarcodeCount> = delim.read_tsv(&hop_metrics).unwrap();
assert_eq!(hop_metrics.len(), 1);
assert_eq!(hop_metrics[0].barcode, "TTT+AAA");
assert_eq!(hop_metrics[0].count, 1);
assert_eq!(hop_metrics[0], BarcodeCount { barcode: "TTT+AAA".to_string(), count: 1 });

// Check unmatched metric, should contain the one hopped barcode
let unmatched_metrics = output.join("most_frequent_unmatched.tsv");

let delim = DelimFile::default();
let unmatched_metrics: Vec<BarcodeCount> = delim.read_tsv(&unmatched_metrics).unwrap();
assert_eq!(unmatched_metrics.len(), 1);
assert_eq!(unmatched_metrics[0].barcode, "TTT+AAA");
assert_eq!(unmatched_metrics[0].count, 1);
assert_eq!(unmatched_metrics[0], BarcodeCount { barcode: "TTT+AAA".to_string(), count: 1 });
}

#[rstest]
Expand Down Expand Up @@ -1602,7 +1600,7 @@ s1,CCC,"#;
let delim = DelimFile::default();
let unmatched_metrics: Vec<BarcodeCount> = delim.read_tsv(&unmatched_metrics).unwrap();
assert_eq!(unmatched_metrics.len(), 1);
assert_eq!(unmatched_metrics[0].barcode, "TTT");
assert_eq!(unmatched_metrics[0], BarcodeCount { barcode: "TTT".to_string(), count: 1 });

// make sure that hop metrics does not exist
let hop_metrics = output.join("sample_barcode_hop_metrics.tsv");
Expand Down

0 comments on commit 0588ccd

Please sign in to comment.