rabbitmq-server/deps/rabbitmq_cli/test/ctl/environment_command_test.exs

46 lines
1.3 KiB
Elixir
Raw Normal View History

## 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/.
2016-02-26 06:13:02 +08:00
##
2020-03-10 22:39:56 +08:00
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
2016-02-26 06:13:02 +08:00
defmodule EnvironmentCommandTest do
use ExUnit.Case, async: false
import TestHelper
@command RabbitMQ.CLI.Ctl.Commands.EnvironmentCommand
2016-06-02 08:22:27 +08:00
2016-02-26 06:13:02 +08:00
setup_all do
2016-11-15 01:52:08 +08:00
RabbitMQ.CLI.Core.Distribution.start()
2016-02-26 06:13:02 +08:00
:ok
end
setup do
2017-01-24 20:33:48 +08:00
{:ok, opts: %{node: get_rabbit_hostname()}}
2016-03-08 06:45:50 +08:00
end
test "validate: argument count validates" do
2016-08-23 21:28:34 +08:00
assert @command.validate([], %{}) == :ok
2016-06-02 08:22:27 +08:00
assert @command.validate(["extra"], %{}) == {:validation_failure, :too_many_args}
end
2017-01-24 20:33:48 +08:00
@tag target: get_rabbit_hostname()
test "run: environment request on a named, active RMQ node is successful", context do
2016-06-02 08:22:27 +08:00
assert @command.run([], context[:opts])[:kernel] != nil
assert @command.run([], context[:opts])[:rabbit] != nil
2016-02-26 06:13:02 +08:00
end
test "run: environment request on nonexistent RabbitMQ node returns a badrpc" do
opts = %{node: :jake@thedog, timeout: 200}
assert match?({:badrpc, _}, @command.run([], opts))
end
test "banner", context do
2016-06-02 08:22:27 +08:00
assert @command.banner([], context[:opts])
2017-01-24 20:33:48 +08:00
=~ ~r/Application environment of node #{get_rabbit_hostname()}/
2016-02-26 06:13:02 +08:00
end
end