diff options
author | dcorbacho <dparracorbacho@piotal.io> | 2020-11-18 14:27:41 +0000 |
---|---|---|
committer | dcorbacho <dparracorbacho@piotal.io> | 2020-11-18 14:27:41 +0000 |
commit | f23a51261d9502ec39df0f8db47ba6b22aa7659f (patch) | |
tree | 53dcdf46e7dc2c14e81ee960bce8793879b488d3 /deps/rabbitmq_cli/test/ctl/stop_command_test.exs | |
parent | afa2c2bf6c7e0e9b63f4fb53dc931c70388e1c82 (diff) | |
parent | 9f6d64ec4a4b1eeac24d7846c5c64fd96798d892 (diff) | |
download | rabbitmq-server-git-f23a51261d9502ec39df0f8db47ba6b22aa7659f.tar.gz |
Merge remote-tracking branch 'origin/master' into stream-timestamp-offsetstream-timestamp-offset
Diffstat (limited to 'deps/rabbitmq_cli/test/ctl/stop_command_test.exs')
-rw-r--r-- | deps/rabbitmq_cli/test/ctl/stop_command_test.exs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/deps/rabbitmq_cli/test/ctl/stop_command_test.exs b/deps/rabbitmq_cli/test/ctl/stop_command_test.exs new file mode 100644 index 0000000000..2f1dca2eae --- /dev/null +++ b/deps/rabbitmq_cli/test/ctl/stop_command_test.exs @@ -0,0 +1,52 @@ +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. + + +defmodule StopCommandTest do + use ExUnit.Case, async: false + import TestHelper + + @command RabbitMQ.CLI.Ctl.Commands.StopCommand + + setup_all do + RabbitMQ.CLI.Core.Distribution.start() + + :ok + end + + setup do + {:ok, opts: %{node: get_rabbit_hostname(), + idempotent: false}} + end + + test "validate accepts no arguments", context do + assert @command.validate([], context[:opts]) == :ok + end + + test "validate accepts a PID file path", context do + assert @command.validate(["/path/to/pidfile.pid"], context[:opts]) == :ok + end + + test "validate: with extra arguments returns an arg count error", context do + assert @command.validate(["/path/to/pidfile.pid", "extra"], context[:opts]) == {:validation_failure, :too_many_args} + end + + # NB: as this commands shuts down the Erlang vm it isn't really practical to test it here + + test "run: request to a non-existent node with --idempotent=false returns a badrpc" do + opts = %{node: :jake@thedog, idempotent: false, timeout: 200} + assert match?({:badrpc, _}, @command.run([], opts)) + end + + test "run: request to a non-existent node with --idempotent returns ok" do + opts = %{node: :jake@thedog, idempotent: true, timeout: 200} + assert match?({:ok, _}, @command.run([], opts)) + end + + test "banner", context do + assert @command.banner([], context[:opts]) =~ ~r/Stopping and halting node #{get_rabbit_hostname()}/ + end +end |