2020-07-12 02:23:07 +08:00
|
|
|
## 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
|
|
|
|
|
2016-06-10 07:54:22 +08:00
|
|
|
@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-03-18 00:48:11 +08:00
|
|
|
|
2016-02-26 06:13:02 +08:00
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
2016-03-18 00:48:11 +08:00
|
|
|
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
|
|
|
|
|
2016-05-24 19:33:11 +08:00
|
|
|
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}
|
2016-03-09 01:05:25 +08:00
|
|
|
end
|
|
|
|
|
2017-01-24 20:33:48 +08:00
|
|
|
@tag target: get_rabbit_hostname()
|
2016-05-24 19:33:11 +08:00
|
|
|
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
|
|
|
|
|
2019-04-12 06:27:15 +08:00
|
|
|
test "run: environment request on nonexistent RabbitMQ node returns a badrpc" do
|
|
|
|
opts = %{node: :jake@thedog, timeout: 200}
|
2017-06-07 23:21:53 +08:00
|
|
|
|
2019-04-12 06:27:15 +08:00
|
|
|
assert match?({:badrpc, _}, @command.run([], opts))
|
2016-05-03 06:01:30 +08:00
|
|
|
end
|
|
|
|
|
2016-05-24 19:33:11 +08:00
|
|
|
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
|