Skip to content

Commit

Permalink
make dialyzer check and tests pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysGonchar committed Aug 3, 2020
1 parent 80aeeac commit decd6a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/amoc_config/amoc_config_scenario.erl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
-include_lib("kernel/include/logger.hrl").
-include("amoc_config.hrl").

-type module_configuration_map() :: #{name() => #{any() => any()}}.
-type module_configuration_map() :: #{name() => #{value := any(),
any() => any()}}.
%% ------------------------------------------------------------------
%% API
%% ------------------------------------------------------------------
Expand Down Expand Up @@ -142,7 +143,7 @@ store_scenario_config(Config) ->
convert_to_config_map(Config) ->
PropList = [{Name, parameter_to_map(P)}
|| #module_parameter{name = Name} = P <- Config],
maps:from_list(PropList).
{ok, maps:from_list(PropList)}.

parameter_to_map(#module_parameter{} = Param) ->
RecordFields = record_info(fields, module_parameter),
Expand Down
6 changes: 3 additions & 3 deletions src/rest_api/amoc_api_scenario_status.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ format(Value) ->

-spec scenario_settings(status(), amoc:scenario()) -> amoc_config:settings().
scenario_settings(loaded, Scenario) ->
ConfigMap = amoc_config_scenario:get_default_configuration(Scenario),
{ok, ConfigMap} = amoc_config_scenario:get_default_configuration(Scenario),
[{Name, Value} || {Name, #{value := Value}} <- maps:to_list(ConfigMap)];
scenario_settings(running, _Scenario) ->
ConfigMap = amoc_config_scenario:get_current_configuration(),
{ok, ConfigMap} = amoc_config_scenario:get_current_configuration(),
[{Name, Value} || {Name, #{value := Value}} <- maps:to_list(ConfigMap)];
scenario_settings(_, _Scenario) -> [].

scenario_parameters(Scenario) ->
ConfigMap = amoc_config_scenario:get_default_configuration(Scenario),
{ok, ConfigMap} = amoc_config_scenario:get_default_configuration(Scenario),
[{Name, maps:to_list(Info)} || {Name, Info} <- maps:to_list(ConfigMap)].

-spec get_scenario(binary()) -> {ok, amoc:scenario()} | doesnt_exist.
Expand Down
14 changes: 9 additions & 5 deletions test/amoc_api_scenario_handler_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ all() ->
patch_scenario_returns_200_when_request_ok_and_module_exists_w_settings
].

init_per_testcase(Mod, Config)
when Mod =:= patch_scenario_returns_200_when_request_ok_and_module_exists;
Mod =:= patch_scenario_returns_200_when_request_ok_and_module_exists_w_settings ->
init_per_testcase(TC, Config)
when TC =:= patch_scenario_returns_200_when_request_ok_and_module_exists;
TC =:= patch_scenario_returns_200_when_request_ok_and_module_exists_w_settings ->
mock_amoc_dist_do(),
create_env(Config),
Config;
Expand All @@ -48,7 +48,9 @@ init_per_testcase(_, Config) ->
create_env(Config),
Config.

end_per_testcase(patch_scenario_returns_200_when_request_ok_and_module_exists, _Config) ->
end_per_testcase(TC, _Config)
when TC =:= patch_scenario_returns_200_when_request_ok_and_module_exists;
TC =:= patch_scenario_returns_200_when_request_ok_and_module_exists_w_settings ->
ok = meck:unload(amoc_dist),
destroy_env();
end_per_testcase(_, _Config) ->
Expand Down Expand Up @@ -178,7 +180,9 @@ destroy_env() ->
-spec given_test_status_mocked(atom()) -> ok.
given_test_status_mocked(Value) ->
meck:new(amoc_api_scenario_status, []),
meck:expect(amoc_api_scenario_status, test_status, fun(_) -> Value end).
meck:expect(amoc_api_scenario_status, test_status, fun(_) -> Value end),
meck:expect(amoc_api_scenario_status, maybe_scenario_settings,
fun(_, _) -> [] end).

-spec mock_amoc_dist_do() -> ok.
mock_amoc_dist_do() ->
Expand Down

0 comments on commit decd6a7

Please sign in to comment.