Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhofer committed Aug 21, 2024
1 parent 3d1b48c commit 23c0c19
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/models/new_edge.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rusqlite::types::Value;
use rusqlite::{params_from_iter, Connection};
use std::collections::HashSet;
use std::collections::{HashMap, HashSet};
use std::hash::RandomState;

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -248,18 +248,20 @@ mod tests {
let edges = NewEdge::bulk_load(conn, edge_ids);
assert_eq!(edges.len(), 3);

let edge_result1 = &edges[0];
assert_eq!(edge_result1.source_hash, NewEdge::PATH_START_HASH);
let edges_by_source_hash = edges
.into_iter()
.map(|edge| (edge.source_hash.clone(), edge))
.collect::<HashMap<String, NewEdge>>();

let edge_result1 = edges_by_source_hash.get(NewEdge::PATH_START_HASH).unwrap();
assert_eq!(edge_result1.source_coordinate, -1);
assert_eq!(edge_result1.target_hash, sequence1_hash);
assert_eq!(edge_result1.target_coordinate, 1);
let edge_result2 = &edges[1];
assert_eq!(edge_result2.source_hash, sequence1_hash);
let edge_result2 = edges_by_source_hash.get(&sequence1_hash).unwrap();
assert_eq!(edge_result2.source_coordinate, 2);
assert_eq!(edge_result2.target_hash, sequence2_hash);
assert_eq!(edge_result2.target_coordinate, 3);
let edge_result3 = &edges[2];
assert_eq!(edge_result3.source_hash, sequence2_hash);
let edge_result3 = edges_by_source_hash.get(&sequence2_hash).unwrap();
assert_eq!(edge_result3.source_coordinate, 4);
assert_eq!(edge_result3.target_hash, NewEdge::PATH_END_HASH);
assert_eq!(edge_result3.target_coordinate, -1);
Expand Down Expand Up @@ -316,21 +318,23 @@ mod tests {
let edges = NewEdge::bulk_load(conn, edge_ids);
assert_eq!(edges.len(), 3);

let edge_result1 = &edges[0];
let edges_by_source_hash = edges
.into_iter()
.map(|edge| (edge.source_hash.clone(), edge))
.collect::<HashMap<String, NewEdge>>();

let edge_result1 = edges_by_source_hash.get(NewEdge::PATH_START_HASH).unwrap();

assert_eq!(edge_result1.id, existing_edge.id);

assert_eq!(edge_result1.source_hash, NewEdge::PATH_START_HASH);
assert_eq!(edge_result1.source_coordinate, -1);
assert_eq!(edge_result1.target_hash, sequence1_hash);
assert_eq!(edge_result1.target_coordinate, 1);
let edge_result2 = &edges[2];
assert_eq!(edge_result2.source_hash, sequence1_hash);
let edge_result2 = edges_by_source_hash.get(&sequence1_hash).unwrap();
assert_eq!(edge_result2.source_coordinate, 2);
assert_eq!(edge_result2.target_hash, sequence2_hash);
assert_eq!(edge_result2.target_coordinate, 3);
let edge_result3 = &edges[1];
assert_eq!(edge_result3.source_hash, sequence2_hash);
let edge_result3 = edges_by_source_hash.get(&sequence2_hash).unwrap();
assert_eq!(edge_result3.source_coordinate, 4);
assert_eq!(edge_result3.target_hash, NewEdge::PATH_END_HASH);
assert_eq!(edge_result3.target_coordinate, -1);
Expand Down

0 comments on commit 23c0c19

Please sign in to comment.