-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from inaka/cabol.321.optional_callbacks
[#321] In `sumo_store` add `handle_info` and `terminate` as optional callbacks
- Loading branch information
Showing
15 changed files
with
298 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[ | ||
{sumo_db, [ | ||
{wpool_opts, [{overrun_warning, 100}]}, | ||
{verbose, true}, | ||
{query_timeout, 30000}, | ||
{storage_backends, [ | ||
{sumo_test_backend_mnesia, sumo_backend_mnesia, []} | ||
]}, | ||
{stores, [ | ||
{sumo_test_mnesia, sumo_store_mnesia, [ | ||
{workers, 10}, | ||
{ram_copies, here}, | ||
{majority, false} | ||
]}, | ||
{sumo_test_store1, sumo_test_store1, [ | ||
{workers, 10}, | ||
{ram_copies, here}, | ||
{majority, false} | ||
]}, | ||
{sumo_test_store2, sumo_test_store2, [ | ||
{workers, 10}, | ||
{ram_copies, here}, | ||
{majority, false} | ||
]}, | ||
{sumo_test_store3, sumo_test_store3, [ | ||
{workers, 10}, | ||
{ram_copies, here}, | ||
{majority, false} | ||
]} | ||
]}, | ||
{docs, [ | ||
{people, sumo_test_mnesia, #{module => sumo_test_people_mnesia}}, | ||
{people1, sumo_test_store1, #{module => sumo_test_people_mnesia}}, | ||
{people2, sumo_test_store2, #{module => sumo_test_people_mnesia}}, | ||
{people3, sumo_test_store3, #{module => sumo_test_people_mnesia}} | ||
]}, | ||
{events, [ | ||
{people, sumo_test_people_events_manager} | ||
]} | ||
]} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/conditional_logic_SUITE.erl → test/sumo_conditionals_SUITE.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
-module(conditional_logic_SUITE). | ||
-module(sumo_conditionals_SUITE). | ||
|
||
%% CT | ||
-export([ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
-module(sumo_optional_callbacks_SUITE). | ||
|
||
-include_lib("common_test/include/ct.hrl"). | ||
|
||
%% CT | ||
-export([ | ||
all/0, | ||
init_per_suite/1, | ||
end_per_suite/1 | ||
]). | ||
|
||
%% Test Cases | ||
-export([ | ||
t_optional_callbacks/1 | ||
]). | ||
|
||
-define(EXCLUDED_FUNS, [ | ||
module_info, | ||
all, | ||
init_per_suite, | ||
end_per_suite | ||
]). | ||
|
||
%%%============================================================================= | ||
%%% Common Test | ||
%%%============================================================================= | ||
|
||
%% @hidden | ||
all() -> | ||
Exports = ?MODULE:module_info(exports), | ||
[F || {F, _} <- Exports, not lists:member(F, ?EXCLUDED_FUNS)]. | ||
|
||
%% @hidden | ||
init_per_suite(Config) -> | ||
ok = sumo_test_utils:start_apps(), | ||
[{schemas, [people1, people2, people3]} | Config]. | ||
|
||
%% @hidden | ||
end_per_suite(Config) -> | ||
_ = application:stop(sumo_db), | ||
Config. | ||
|
||
%%%============================================================================= | ||
%%% Test Cases | ||
%%%============================================================================= | ||
|
||
%% @hidden | ||
t_optional_callbacks(Config) -> | ||
run_for_all_schemas(Config, fun t_optional_callbacks_/1). | ||
|
||
%% @hidden | ||
t_optional_callbacks_(SchemaName) -> | ||
_ = sumo:call(SchemaName, send_msg, [noreply]), | ||
_ = sumo:call(SchemaName, send_msg, [hibernate]), | ||
_ = sumo:call(SchemaName, send_msg, [timeout]), | ||
_ = sumo:call(SchemaName, send_msg, [stop]), | ||
_ = sumo:call(SchemaName, send_msg, [throw]), | ||
ok. | ||
|
||
%%%============================================================================= | ||
%%% Internal Functions | ||
%%%============================================================================= | ||
|
||
%% @private | ||
run_for_all_schemas(Config, Fun) -> | ||
{_, Schemas} = lists:keyfind(schemas, 1, Config), | ||
lists:foreach(Fun, Schemas). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-module(sumo_test_store1). | ||
|
||
-behaviour(sumo_store). | ||
|
||
%% @todo remove this once mixer migrates specs better | ||
-dialyzer([no_behaviours]). | ||
|
||
-include_lib("mixer/include/mixer.hrl"). | ||
-mixin([ | ||
{sumo_store_mnesia, [ | ||
init/1, | ||
create_schema/2, | ||
persist/2, | ||
fetch/3, | ||
delete_by/3, | ||
delete_all/2, | ||
find_all/2, find_all/5, | ||
find_by/3, find_by/5, find_by/6, | ||
count/2, | ||
count_by/3 | ||
]} | ||
]). | ||
|
||
-export([send_msg/3]). | ||
|
||
%% @hidden | ||
send_msg(noreply, _DocName, State) -> | ||
{ok, {raw, send({noreply, State})}, State}; | ||
send_msg(hibernate, _DocName, State) -> | ||
{ok, {raw, send({noreply, State, hibernate})}, State}; | ||
send_msg(timeout, _DocName, State) -> | ||
{ok, {raw, send({noreply, State, 1})}, State}; | ||
send_msg(stop, DocName, State) -> | ||
{ok, {raw, send({stop, DocName, State})}, State}; | ||
send_msg(throw, _DocName, State) -> | ||
{ok, {raw, send(throw)}, State}; | ||
send_msg(terminate, _DocName, State) -> | ||
{ok, {raw, send(terminate)}, State}. | ||
|
||
%% @private | ||
send(Msg) -> | ||
self() ! Msg, | ||
ok. |
Oops, something went wrong.