Skip to content

Commit

Permalink
Add transaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
issackelly committed Nov 29, 2022
1 parent d9b683c commit 2da718d
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions autosurgeon/src/reconcile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,4 +1067,53 @@ mod tests {
}}
);
}

fn test_prop_with_transaction() {
let mut doc = automerge::Automerge::new();
let mut tx = doc.transaction();

let bob = Contact {
name: "bob".to_string(),
id: 1,
addresses: vec![Address {
line_one: "line one".to_string(),
line_two: "line two".to_string(),
}],
};
reconcile(&mut tx, &bob).unwrap();
tx.commit();

assert_doc!(
&doc,
map! {
"name" => { "bob" },
"id" => { 1_u64 },
"addresses" => { list!{
{ map! {
"line_one" => { "line one" },
"line_two" => { "line two" },
}}
}
}}
);

let mut tx = doc.transaction();
reconcile_prop(&mut tx, automerge::ROOT, "name", "Alice".to_owned()).unwrap();
tx.commit();

assert_doc!(
&doc,
map! {
"name" => { "alice" },
"id" => { 1_u64 },
"addresses" => { list!{
{ map! {
"line_one" => { "line one" },
"line_two" => { "line two" },
}}
}
}}
);

}
}

0 comments on commit 2da718d

Please sign in to comment.