diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2012-04-05 12:16:38 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2012-04-05 12:16:38 +0100 |
| commit | 836275663ab8d7e866df6f83b86c920e23c54809 (patch) | |
| tree | 74f62eee4b7e6b6625b1964175b83307e143d2c0 | |
| parent | 1c0b948a2e25331da78ee0e9948e6fe47dd3eafe (diff) | |
| download | rabbitmq-server-git-836275663ab8d7e866df6f83b86c920e23c54809.tar.gz | |
Tests
| -rw-r--r-- | src/rabbit_runtime_parameters_test.erl | 31 | ||||
| -rw-r--r-- | src/rabbit_tests.erl | 31 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/rabbit_runtime_parameters_test.erl b/src/rabbit_runtime_parameters_test.erl new file mode 100644 index 0000000000..24cdfce901 --- /dev/null +++ b/src/rabbit_runtime_parameters_test.erl @@ -0,0 +1,31 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License +%% at http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and +%% limitations under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developer of the Original Code is VMware, Inc. +%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved. +%% + +-module(rabbit_runtime_parameters_test). +-behaviour(rabbit_runtime_parameter). + +-export([validate/3, notify/3, notify_clear/2]). +-export([register/0]). + +register() -> + rabbit_registry:register(runtime_parameter, <<"test">>, ?MODULE). + +validate(<<"test">>, <<"good">>, _Term) -> ok; +validate(<<"test">>, <<"maybe">>, <<"good">>) -> ok; +validate(<<"test">>, _, _) -> {error, "meh", []}. + +notify(_, _, _) -> ok. +notify_clear(_, _) -> ok. diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 55e4a6f854..d80f3162b5 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -53,6 +53,7 @@ all_tests() -> passed = test_option_parser(), passed = test_cluster_management(), passed = test_user_management(), + passed = test_runtime_parameters(), passed = test_server_status(), passed = test_confirms(), passed = maybe_run_cluster_dependent_tests(), @@ -1096,6 +1097,36 @@ test_user_management() -> passed. +test_runtime_parameters() -> + rabbit_runtime_parameters_test:register(), + Good = fun(L) -> ok = control_action(set_parameter, L) end, + Bad = fun(L) -> {error_string, _} = control_action(set_parameter, L) end, + + %% Acceptable for bijection + Good(["test", "good", "<<\"ignore\">>"]), + Good(["test", "good", "123"]), + Good(["test", "good", "true"]), + Good(["test", "good", "false"]), + Good(["test", "good", "null"]), + Good(["test", "good", "[{<<\"key\">>, <<\"value\">>}]"]), + + %% Various forms of fail due to non-bijectability + Bad(["test", "good", "atom"]), + Bad(["test", "good", "{tuple, foo}"]), + Bad(["test", "good", "[{<<\"key\">>, <<\"value\">>, 1}]"]), + Bad(["test", "good", "[{key, <<\"value\">>}]"]), + + %% Test actual validation hook + Good(["test", "maybe", "<<\"good\">>"]), + Bad(["test", "maybe", "<<\"bad\">>"]), + + ok = control_action(list_parameters, []), + + ok = control_action(clear_parameter, ["test", "good"]), + ok = control_action(clear_parameter, ["test", "maybe"]), + + passed. + test_server_status() -> %% create a few things so there is some useful information to list Writer = spawn(fun () -> receive shutdown -> ok end end), |
