Skip to content

Commit

Permalink
antidote-crdt: add tests for multi ops on same key (map types)
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idpwn committed May 30, 2022
1 parent ae3dcce commit 181b915
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/antidote_crdt/src/antidote_crdt_map_go.erl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ update2_test() ->
Map1 = new(),
{ok, Effect1} = downstream({update, [{{a, antidote_crdt_set_aw}, {add, a}}]}, Map1),
{ok, Map2} = update(Effect1, Map1),
?assertEqual([{{a, antidote_crdt_set_aw}, [a]}], value(Map2)).
{ok, Effect2} = downstream(
{update, [
{{a, antidote_crdt_set_aw}, {remove, a}},
{{a, antidote_crdt_set_aw}, {add, b}}
]},
Map2
),
{ok, Map3} = update(Effect2, Map2),
?assertEqual([{{a, antidote_crdt_set_aw}, [a]}], value(Map2)),
?assertEqual([{{a, antidote_crdt_set_aw}, [b]}], value(Map3)).

-endif.
10 changes: 10 additions & 0 deletions apps/antidote_crdt/src/antidote_crdt_map_rr.erl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,16 @@ upd(Update, State) ->
{ok, Res} = update(Downstream, State),
Res.

multiple_ops_on_same_key_test() ->
M1 = new(),
M2 = upd({update, {{a, antidote_crdt_set_rw}, {add, <<"a">>}}}, M1),
M3 = upd(
{update, [
{{a, antidote_crdt_set_rw}, {remove, <<"a">>}},
{{a, antidote_crdt_set_rw}, {add, <<"b">>}}
]}, M2),
?assertEqual([{{a, antidote_crdt_set_rw}, [<<"b">>]}], value(M3)).

remove_test() ->
M1 = new(),
?assertEqual([], value(M1)),
Expand Down

0 comments on commit 181b915

Please sign in to comment.