Skip to content

Commit a3a521c

Browse files
author
Alex Valiushko
committed
mix format
1 parent 7e0f488 commit a3a521c

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/add_member_command.ex

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ defmodule RabbitMQ.CLI.Queues.Commands.AddMemberCommand do
1010

1111
@behaviour RabbitMQ.CLI.CommandBehaviour
1212

13-
defp default_opts, do: %{vhost: "/",
14-
membership: "promotable",
15-
timeout: 5_000}
13+
defp default_opts, do: %{vhost: "/", membership: "promotable", timeout: 5_000}
1614

1715
def merge_defaults(args, opts) do
1816
default = default_opts()
19-
opts = Map.update(opts, :timeout, :infinity,
20-
&(case &1 do
21-
:infinity -> default.timeout
22-
other -> other
23-
end))
17+
18+
opts =
19+
Map.update(
20+
opts,
21+
:timeout,
22+
:infinity,
23+
&case &1 do
24+
:infinity -> default.timeout
25+
other -> other
26+
end
27+
)
28+
2429
{args, Map.merge(default, opts)}
2530
end
2631

@@ -40,9 +45,10 @@ defmodule RabbitMQ.CLI.Queues.Commands.AddMemberCommand do
4045
{:validation_failure, :too_many_args}
4146
end
4247

43-
def validate(_, %{membership: m}) when not (m == "promotable" or
44-
m == "non_voter" or
45-
m == "voter") do
48+
def validate(_, %{membership: m})
49+
when not (m == "promotable" or
50+
m == "non_voter" or
51+
m == "voter") do
4652
{:validation_failure, "voter status '#{m}' is not recognised."}
4753
end
4854

@@ -63,8 +69,10 @@ defmodule RabbitMQ.CLI.Queues.Commands.AddMemberCommand do
6369
)
6470
end
6571

66-
def run([name, node] = _args,
67-
%{vhost: vhost, node: node_name, timeout: timeout, membership: membership}) do
72+
def run(
73+
[name, node] = _args,
74+
%{vhost: vhost, node: node_name, timeout: timeout, membership: membership}
75+
) do
6876
case :rabbit_misc.rpc_call(node_name, :rabbit_quorum_queue, :add_member, [
6977
vhost,
7078
name,

deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/grow_command.ex

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
1010

1111
@behaviour RabbitMQ.CLI.CommandBehaviour
1212

13-
defp default_opts, do: %{vhost_pattern: ".*",
14-
queue_pattern: ".*",
15-
membership: "promotable",
16-
errors_only: false}
13+
defp default_opts,
14+
do: %{vhost_pattern: ".*", queue_pattern: ".*", membership: "promotable", errors_only: false}
1715

1816
def switches(),
1917
do: [
@@ -35,14 +33,16 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
3533
{:validation_failure, :too_many_args}
3634
end
3735

38-
def validate([_, s], _) when not (s == "all" or
39-
s == "even") do
36+
def validate([_, s], _)
37+
when not (s == "all" or
38+
s == "even") do
4039
{:validation_failure, "strategy '#{s}' is not recognised."}
4140
end
4241

43-
def validate(_, %{membership: m}) when not (m == "promotable" or
44-
m == "non_voter" or
45-
m == "voter") do
42+
def validate(_, %{membership: m})
43+
when not (m == "promotable" or
44+
m == "non_voter" or
45+
m == "voter") do
4646
{:validation_failure, "voter status '#{m}' is not recognised."}
4747
end
4848

@@ -105,7 +105,8 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
105105
def formatter(), do: RabbitMQ.CLI.Formatters.Table
106106

107107
def usage,
108-
do: "grow <node> <all | even> [--vhost-pattern <pattern>] [--queue-pattern <pattern>] [--membership <promotable|voter>]"
108+
do:
109+
"grow <node> <all | even> [--vhost-pattern <pattern>] [--queue-pattern <pattern>] [--membership <promotable|voter>]"
109110

110111
def usage_additional do
111112
[

deps/rabbitmq_cli/test/queues/add_member_command_test.exs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ defmodule RabbitMQ.CLI.Queues.Commands.AddMemberCommandTest do
4545
end
4646

4747
test "validate: when membership promotable is provided, returns a success" do
48-
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{membership: "promotable"}) == :ok
48+
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{membership: "promotable"}) ==
49+
:ok
4950
end
5051

5152
test "validate: when membership voter is provided, returns a success" do
5253
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{membership: "voter"}) == :ok
5354
end
5455

5556
test "validate: when membership non_voter is provided, returns a success" do
56-
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{membership: "non_voter"}) == :ok
57+
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{membership: "non_voter"}) ==
58+
:ok
5759
end
5860

5961
test "validate: when wrong membership is provided, returns failure" do
6062
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{membership: "banana"}) ==
6163
{:validation_failure, "voter status 'banana' is not recognised."}
6264
end
6365

64-
6566
test "validate: treats two positional arguments and default switches as a success" do
6667
assert @command.validate(["quorum-queue-a", "rabbit@new-node"], %{}) == :ok
6768
end

deps/rabbitmq_cli/test/queues/grow_command_test.exs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommandTest do
3030

3131
test "merge_defaults: defaults to reporting complete results" do
3232
assert @command.merge_defaults([], %{}) ==
33-
{[], %{vhost_pattern: ".*", queue_pattern: ".*", errors_only: false, membership: "promotable"}}
33+
{[],
34+
%{
35+
vhost_pattern: ".*",
36+
queue_pattern: ".*",
37+
errors_only: false,
38+
membership: "promotable"
39+
}}
3440
end
3541

3642
test "validate: when no arguments are provided, returns a failure" do

0 commit comments

Comments
 (0)