|
7 | 7 | defmodule ListPluginsCommandTest do
|
8 | 8 | use ExUnit.Case, async: false
|
9 | 9 | import TestHelper
|
| 10 | + import ExUnit.CaptureIO |
10 | 11 |
|
11 | 12 | @command RabbitMQ.CLI.Plugins.Commands.ListCommand
|
12 | 13 |
|
@@ -444,4 +445,126 @@ defmodule ListPluginsCommandTest do
|
444 | 445 |
|
445 | 446 | assert_plugin_states(actual_plugins2, expected_plugins2)
|
446 | 447 | end
|
| 448 | + |
| 449 | + test "run: lists all plugins with missing plugins warning control using --silent", context do |
| 450 | + opts = |
| 451 | + context[:opts] |
| 452 | + |> Map.put_new(:silent, true) |
| 453 | + |> Map.put_new(:hard_write, true) |
| 454 | + |
| 455 | + context = Map.replace(context, :opts, opts) |
| 456 | + |
| 457 | + missing_plugin = :rabbitmq_non_existent |
| 458 | + |
| 459 | + reset_enabled_plugins_to_preconfigured_defaults(context) |
| 460 | + |
| 461 | + set_enabled_plugins( |
| 462 | + [:rabbitmq_federation, missing_plugin], |
| 463 | + :online, |
| 464 | + context[:opts][:node], |
| 465 | + context[:opts] |
| 466 | + ) |
| 467 | + |
| 468 | + on_exit(fn -> |
| 469 | + opts = |
| 470 | + context[:opts] |
| 471 | + |> Map.delete(:silent) |
| 472 | + |> Map.delete(:hard_write) |
| 473 | + |
| 474 | + context = Map.replace(context, :opts, opts) |
| 475 | + |
| 476 | + set_enabled_plugins( |
| 477 | + [:rabbitmq_stomp, :rabbitmq_federation], |
| 478 | + :online, |
| 479 | + context[:opts][:node], |
| 480 | + context[:opts] |
| 481 | + ) |
| 482 | + end) |
| 483 | + |
| 484 | + expected_plugins = [ |
| 485 | + %{name: :rabbitmq_federation, enabled: :enabled, running: true}, |
| 486 | + %{name: :rabbitmq_stomp, enabled: :not_enabled, running: false} |
| 487 | + ] |
| 488 | + |
| 489 | + opts = context[:opts] |
| 490 | + |
| 491 | + assert capture_io(fn -> |
| 492 | + %{ |
| 493 | + plugins: actual_plugins |
| 494 | + } = @command.run([".*"], opts) |
| 495 | + |
| 496 | + assert_plugin_states(actual_plugins, expected_plugins) |
| 497 | + end) =~ ~s// |
| 498 | + |
| 499 | + opts = Map.replace(opts, :silent, false) |
| 500 | + |
| 501 | + assert capture_io(fn -> |
| 502 | + %{ |
| 503 | + plugins: actual_plugins |
| 504 | + } = @command.run([".*"], opts) |
| 505 | + |
| 506 | + assert_plugin_states(actual_plugins, expected_plugins) |
| 507 | + end) =~ ~s/WARNING - plugins currently enabled but missing: #{missing_plugin}\n/ |
| 508 | + end |
| 509 | + |
| 510 | + test "run: lists all plugins with missing plugins warning control using --quiet", context do |
| 511 | + opts = |
| 512 | + context[:opts] |
| 513 | + |> Map.put_new(:quiet, true) |
| 514 | + |> Map.put_new(:hard_write, true) |
| 515 | + |
| 516 | + context = Map.replace(context, :opts, opts) |
| 517 | + |
| 518 | + missing_plugin = :rabbitmq_non_existent |
| 519 | + |
| 520 | + reset_enabled_plugins_to_preconfigured_defaults(context) |
| 521 | + |
| 522 | + set_enabled_plugins( |
| 523 | + [:rabbitmq_federation, missing_plugin], |
| 524 | + :online, |
| 525 | + context[:opts][:node], |
| 526 | + context[:opts] |
| 527 | + ) |
| 528 | + |
| 529 | + on_exit(fn -> |
| 530 | + opts = |
| 531 | + context[:opts] |
| 532 | + |> Map.delete(:quiet) |
| 533 | + |> Map.delete(:hard_write) |
| 534 | + |
| 535 | + context = Map.replace(context, :opts, opts) |
| 536 | + |
| 537 | + set_enabled_plugins( |
| 538 | + [:rabbitmq_stomp, :rabbitmq_federation], |
| 539 | + :online, |
| 540 | + context[:opts][:node], |
| 541 | + context[:opts] |
| 542 | + ) |
| 543 | + end) |
| 544 | + |
| 545 | + expected_plugins = [ |
| 546 | + %{name: :rabbitmq_federation, enabled: :enabled, running: true}, |
| 547 | + %{name: :rabbitmq_stomp, enabled: :not_enabled, running: false} |
| 548 | + ] |
| 549 | + |
| 550 | + opts = context[:opts] |
| 551 | + |
| 552 | + assert capture_io(fn -> |
| 553 | + %{ |
| 554 | + plugins: actual_plugins |
| 555 | + } = @command.run([".*"], opts) |
| 556 | + |
| 557 | + assert_plugin_states(actual_plugins, expected_plugins) |
| 558 | + end) =~ ~s// |
| 559 | + |
| 560 | + opts = Map.replace(opts, :quiet, false) |
| 561 | + |
| 562 | + assert capture_io(fn -> |
| 563 | + %{ |
| 564 | + plugins: actual_plugins |
| 565 | + } = @command.run([".*"], opts) |
| 566 | + |
| 567 | + assert_plugin_states(actual_plugins, expected_plugins) |
| 568 | + end) =~ ~s/WARNING - plugins currently enabled but missing: #{missing_plugin}\n/ |
| 569 | + end |
447 | 570 | end
|
0 commit comments