Skip to content

Commit

Permalink
add ProfileIds unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mxfactorial committed May 6, 2024
1 parent a591a65 commit f73f90f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/types/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ impl From<Vec<(String, String)>> for ProfileIds {
fn from(vec: Vec<(String, String)>) -> Self {
let mut map = HashMap::new();
for (k, v) in vec {
map.insert(v, k.parse::<i32>().unwrap());
let account_name = k.clone();
let profile_id = v.parse::<i32>().unwrap();
map.insert(account_name, profile_id);
}
ProfileIds(map)
}
Expand Down Expand Up @@ -429,6 +431,19 @@ mod tests {
panic!("got {:#?}, want {:#?}", got, want);
}
}

#[test]
fn it_creates_profile_ids_from_vec() {
let want = ProfileIds(HashMap::from_iter(vec![
(String::from("account_a"), 1),
(String::from("account_b"), 2),
(String::from("account_c"), 3),
]));
let got = ProfileIds::from(vec![
// init vec with (String, String) tuples
]);
assert_eq!(got, want, "got {:?}, want {:?}", got, want)
}
}

#[derive(Eq, PartialEq, Debug, Deserialize)]
Expand Down

0 comments on commit f73f90f

Please sign in to comment.