1+ % % The contents of this file are subject to the Mozilla Public License
2+ % % Version 1.1 (the "License"); you may not use this file except in
3+ % % compliance with the License. You may obtain a copy of the License
4+ % % at http://www.mozilla.org/MPL/
5+ % %
6+ % % Software distributed under the License is distributed on an "AS IS"
7+ % % basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8+ % % the License for the specific language governing rights and
9+ % % limitations under the License.
10+ % %
11+ % % The Original Code is RabbitMQ.
12+ % %
13+ % % The Initial Developer of the Original Code is GoPivotal, Inc.
14+ % % Copyright (c) 2017 Pivotal Software, Inc. All rights reserved.
15+ % %
16+
17+
18+ -module (term_to_binary_compat_prop_SUITE ).
19+
20+ -compile (export_all ).
21+
22+ -include (" rabbit.hrl" ).
23+ -include_lib (" common_test/include/ct.hrl" ).
24+ -include_lib (" proper/include/proper.hrl" ).
25+
26+ all () ->
27+ % % The test should run on OTP < 20 (erts < 9)
28+ case erts_gt_8 () of
29+ true ->
30+ [];
31+ false ->
32+ [queue_name_to_binary ]
33+ end .
34+
35+ erts_gt_8 () ->
36+ Vsn = erlang :system_info (version ),
37+ [Maj |_ ] = string :tokens (Vsn , " ." ),
38+ list_to_integer (Maj ) > 8 .
39+
40+ init_per_suite (Config ) ->
41+ rabbit_ct_helpers :log_environment (),
42+ rabbit_ct_helpers :run_setup_steps (Config ).
43+
44+ end_per_suite (Config ) ->
45+ rabbit_ct_helpers :run_teardown_steps (Config ).
46+
47+ init_per_testcase (Testcase , Config ) ->
48+ rabbit_ct_helpers :testcase_started (Config , Testcase ).
49+
50+ queue_name_to_binary (Config ) ->
51+ Fun = fun () -> prop_queue_name_to_binary (Config ) end ,
52+ rabbit_ct_proper_helpers :run_proper (Fun , [], 10000 ).
53+
54+
55+ prop_queue_name_to_binary (_Config ) ->
56+ ? FORALL ({Vhost , QName }, {binary (), binary ()},
57+ begin
58+ Resource = rabbit_misc :r (Vhost , queue , QName ),
59+ Legacy = term_to_binary_compat :queue_name_to_binary (Resource ),
60+ Current = term_to_binary (Resource ),
61+ Current =:= Legacy
62+ end ).
0 commit comments