[squash] Add tests for add stronger config set/get/delete testing
diff --git a/test/config_tests.erl b/test/config_tests.erl
index c823d3e..778e383 100644
--- a/test/config_tests.erl
+++ b/test/config_tests.erl
@@ -116,7 +116,7 @@
should_return_undefined_atom_on_missed_option(),
should_return_custom_default_value_on_missed_option(),
should_only_return_default_on_missed_option(),
- should_fail_to_get_binary_value(),
+ should_fail_to_get_non_string_value(),
should_return_any_supported_default()
]
}
@@ -131,7 +131,7 @@
[
should_update_option(),
should_create_new_section(),
- should_fail_to_set_binary_value()
+ should_fail_to_set_non_string_value()
]
}
}.
@@ -144,7 +144,8 @@
fun setup/0, fun teardown/1,
[
should_return_undefined_atom_after_option_deletion(),
- should_be_ok_on_deleting_unknown_options()
+ should_be_ok_on_deleting_unknown_options(),
+ should_fail_to_delete_non_string_value()
]
}
}.
@@ -243,9 +244,11 @@
?_assertEqual("0",
config:get("httpd", "port", "bar")).
-should_fail_to_get_binary_value() ->
+should_fail_to_get_non_string_value() ->
?_assertException(error, badarg,
- config:get(<<"foo">>, <<"bar">>, <<"baz">>)).
+ config:get(<<"foo">>, <<"bar">>, <<"baz">>)),
+ ?_assertException(error, badarg,
+ config:get([f, o, o], [b, a, r], [b, a, z])).
should_return_any_supported_default() ->
Values = [undefined, "list", true, false, 0.1, 1],
@@ -269,9 +272,11 @@
config:get("new_section", "bizzle")
end).
-should_fail_to_set_binary_value() ->
+should_fail_to_set_non_string_value() ->
?_assertException(error, badarg,
- config:set(<<"foo">>, <<"bar">>, <<"baz">>, false)).
+ config:set(<<"foo">>, <<"bar">>, <<"baz">>, false)),
+ ?_assertException(error, badarg,
+ config:set([f, o, o], [b, a, r], [b, a, z], false)).
should_return_undefined_atom_after_option_deletion() ->
?_assertEqual(undefined,
@@ -283,6 +288,12 @@
should_be_ok_on_deleting_unknown_options() ->
?_assertEqual(ok, config:delete("zoo", "boo", false)).
+should_fail_to_delete_non_string_value() ->
+ ?_assertException(error, badarg,
+ config:delete(<<"foo">>, <<"bar">>, false)),
+ ?_assertException(error, badarg,
+ config:delete([f, o, o], [b, a, r], false)).
+
should_ensure_in_defaults(_, _) ->
?_test(begin
?assertEqual("500",