Class: PluginManagerCliUpdate
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- PluginManagerCliUpdate
- Includes:
- CorePluginFunctionalHelper, PluginManagerHelpers
- Defined in:
- lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb
Overview
—————————————————————————————–#
inspec plugin update
—————————————————————————————–#
Constant Summary
Constants included from CorePluginFunctionalHelper
CorePluginFunctionalHelper::TRAIN_CONNECTION
Instance Method Summary collapse
- #test_fail_update_from_nonexistant_gem ⇒ Object
- #test_fail_update_path ⇒ Object
- #test_refuse_update_when_already_current ⇒ Object
- #test_when_a_plugin_can_be_updated ⇒ Object
Methods included from PluginManagerHelpers
#clear_empty_config_dir, #copy_in_core_config_dir, #copy_in_project_config_dir, #setup, #teardown
Methods included from CorePluginFunctionalHelper
#__find_plugin_path_from_caller, #__make_empty_plugin_file_data_structure, #__make_plugin_file_data_structure_with_path, #run_inspec_process, #run_inspec_process_with_this_plugin
Instance Method Details
#test_fail_update_from_nonexistant_gem ⇒ Object
639 640 641 642 643 644 645 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 639 def test_fail_update_from_nonexistant_gem update_result = run_inspec_process_with_this_plugin("plugin update inspec-test-fixture-nonesuch") assert_empty update_result.stderr assert_equal 1, update_result.exit_status, "Exit status should be 1" assert_match(/No such plugin installed: .+ - update failed/, update_result.stdout) end |
#test_fail_update_path ⇒ Object
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 647 def test_fail_update_path pre_block = Proc.new do |plugin_statefile_data, tmp_dir| plugin_statefile_data.clear # Signal not to write a file, we'll provide one. copy_in_core_config_dir("meaning_by_path", tmp_dir) end update_result = run_inspec_process_with_this_plugin("plugin update inspec-meaning-of-life", pre_run: pre_block) assert_empty update_result.stderr assert_equal 2, update_result.exit_status, "Exit status should be 2" = update_result.stdout.split("\n").grep(/refusing/).last refute_nil , "Should find a failure message at the end" assert_includes , "inspec-meaning-of-life" assert_includes , "inspec plugin uninstall" assert_includes , "Cannot update path-based install" end |
#test_refuse_update_when_already_current ⇒ Object
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 622 def test_refuse_update_when_already_current pre_block = Proc.new do |plugin_statefile_data, tmp_dir| plugin_statefile_data.clear # Signal not to write a file, we'll provide one. copy_in_core_config_dir("test-fixture-2-float", tmp_dir) end update_result = run_inspec_process_with_this_plugin("plugin update inspec-test-fixture", pre_run: pre_block) assert_empty update_result.stderr assert_equal 2, update_result.exit_status, "Exit status should be 2" = update_result.stdout.split("\n").grep(/refusing/).last refute_nil , "Should find a failure message at the end" assert_includes , "inspec-test-fixture" assert_includes , "0.2.0" assert_includes , "Already installed at latest version" end |
#test_when_a_plugin_can_be_updated ⇒ Object
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 597 def test_when_a_plugin_can_be_updated skip "this test requires bundler to pass" unless defined? ::Bundler pre_block = Proc.new do |plugin_statefile_data, tmp_dir| plugin_statefile_data.clear # Signal not to write a file, we'll provide one. copy_in_core_config_dir("test-fixture-1-float", tmp_dir) end update_result = run_inspec_process_with_this_plugin("plugin update inspec-test-fixture", pre_run: pre_block, post_run: list_after_run) assert_empty update_result.stderr assert_equal 0, update_result.exit_status, "Exit status should be 0" = update_result.stdout.split("\n").grep(/updated/).last refute_nil , "Should find a success message at the end" assert_includes , "inspec-test-fixture" assert_includes , "0.1.0" assert_includes , "0.2.0" assert_includes , "updated from rubygems.org" list_result = update_result.payload.list_result itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first refute_nil itf_line, "inspec-test-fixture should appear in the output of inspec list" assert_match(/\s*inspec-test-fixture\s+0.2.0\s+gem\s+/, itf_line, "list output should show that it is a gem installation with version 0.2.0") end |