Skip to content

Commit 4e58ad9

Browse files
CLI: two more test suites
1 parent a88c221 commit 4e58ad9

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
##
5+
## Copyright (c) 2007-2023 VMware, Inc. or its affiliates. All rights reserved.
6+
7+
defmodule RabbitMQ.CLI.Queues.Commands.ListOperatorPoliciesWithClassicQueueMirroringCommandTest do
8+
use ExUnit.Case, async: false
9+
import TestHelper
10+
11+
@command RabbitMQ.CLI.Queues.Commands.ListOperatorPoliciesWithClassicQueueMirroringCommand
12+
13+
setup_all do
14+
RabbitMQ.CLI.Core.Distribution.start()
15+
16+
:ok
17+
end
18+
19+
setup context do
20+
{:ok,
21+
opts: %{
22+
node: get_rabbit_hostname(),
23+
timeout: context[:test_timeout] || 30000
24+
}}
25+
end
26+
27+
test "validate: treats no arguments as a success" do
28+
assert @command.validate([], %{}) == :ok
29+
end
30+
31+
test "validate: accepts no positional arguments" do
32+
assert @command.validate(["arg"], %{}) == {:validation_failure, :too_many_args}
33+
end
34+
35+
test "validate: when two or more arguments are provided, returns a failure" do
36+
assert @command.validate(["arg1", "arg2"], %{}) ==
37+
{:validation_failure, :too_many_args}
38+
39+
assert @command.validate(["arg1", "arg2", "arg3"], %{}) ==
40+
{:validation_failure, :too_many_args}
41+
end
42+
43+
@tag test_timeout: 3000
44+
test "run: targeting an unreachable node throws a badrpc" do
45+
assert match?(
46+
{:badrpc, _},
47+
@command.run(
48+
[],
49+
%{node: :jake@thedog, vhost: "/", timeout: 200}
50+
)
51+
)
52+
end
53+
end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
##
5+
## Copyright (c) 2007-2023 VMware, Inc. or its affiliates. All rights reserved.
6+
7+
defmodule RabbitMQ.CLI.Queues.Commands.ListPoliciesWithClassicQueueMirroringCommandTest do
8+
use ExUnit.Case, async: false
9+
import TestHelper
10+
11+
@command RabbitMQ.CLI.Queues.Commands.ListPoliciesWithClassicQueueMirroringCommand
12+
13+
setup_all do
14+
RabbitMQ.CLI.Core.Distribution.start()
15+
16+
:ok
17+
end
18+
19+
setup context do
20+
{:ok,
21+
opts: %{
22+
node: get_rabbit_hostname(),
23+
timeout: context[:test_timeout] || 30000
24+
}}
25+
end
26+
27+
test "validate: treats no arguments as a success" do
28+
assert @command.validate([], %{}) == :ok
29+
end
30+
31+
test "validate: accepts no positional arguments" do
32+
assert @command.validate(["arg"], %{}) == {:validation_failure, :too_many_args}
33+
end
34+
35+
test "validate: when two or more arguments are provided, returns a failure" do
36+
assert @command.validate(["arg1", "arg2"], %{}) ==
37+
{:validation_failure, :too_many_args}
38+
39+
assert @command.validate(["arg1", "arg2", "arg3"], %{}) ==
40+
{:validation_failure, :too_many_args}
41+
end
42+
43+
@tag test_timeout: 3000
44+
test "run: targeting an unreachable node throws a badrpc" do
45+
assert match?(
46+
{:badrpc, _},
47+
@command.run(
48+
[],
49+
%{node: :jake@thedog, vhost: "/", timeout: 200}
50+
)
51+
)
52+
end
53+
end

0 commit comments

Comments
 (0)