Add gm_ctflow_state

This commit is contained in:
Ulf Wiger
2026-05-24 22:30:57 +02:00
parent 62161193c5
commit 2ea1966973
4 changed files with 95 additions and 4 deletions
+26 -3
View File
@@ -11,7 +11,10 @@
]).
%% test cases
-export([ init_counter/1
-export([ put_a/1
, get_a/1
, erase_a/1
, init_counter/1
, incr/1
, check1/1
, check2/1
@@ -27,12 +30,17 @@
all() ->
[
{group, statefuns}
{group, state}
, {group, statefuns}
, {group, workers}
].
groups() ->
[ {statefuns, [sequence], [ init_counter
[ {state, [sequence], [ put_a
, get_a
, erase_a
]}
, {statefuns, [sequence], [ init_counter
, incr
, check1 %% state = 1
, incr
@@ -71,6 +79,21 @@ init_per_testcase(_Case, Config) ->
end_per_testcase(_Case, _Config) ->
ok.
%% ======================================================================
%% State update commands
put_a(_Cfg) ->
ok = gm_ctflow:put(a, 1),
?assertMatch(1, gm_ctflow:get(a)).
get_a(_Cfg) ->
?assertMatch(1, gm_ctflow:get(a)).
erase_a(_Cfg) ->
ok = gm_ctflow:erase(a),
?assertException(error, {no_such_key,a}, gm_ctflow:get(a)),
?assertMatch(undefined, gm_ctflow:get(a, undefined)).
%% ======================================================================
%% This is our 'ctflow_fun' instance, which floats above some simple
%% test cases. In this test suite, we only exercise the flow funs, but