Class: PluginManagerCliList
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- PluginManagerCliList
- Includes:
- CorePluginFunctionalHelper, PluginManagerHelpers
- Defined in:
- lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb
Overview
—————————————————————————————–#
inspec plugin list
—————————————————————————————–#
Constant Summary collapse
- LIST_CASES =
Listing all plugins is now default behavior
[ { arg: "-c", name: "inspec-plugin-manager-cli", type: "core" }, { arg: "-c", name: "inspec-supermarket", type: "core" }, { arg: "-s", name: "train-aws", type: "gem (system)" }, ].freeze
Constants included from CorePluginFunctionalHelper
CorePluginFunctionalHelper::TRAIN_CONNECTION
Instance Method Summary collapse
- #test_list_all_when_no_user_plugins_installed ⇒ Object
- #test_list_selective_when_no_user_plugins_installed ⇒ Object
- #test_list_when_a_train_plugin_is_installed ⇒ Object
- #test_list_when_gem_and_path_plugins_installed ⇒ Object
Methods included from PluginManagerHelpers
#clear_empty_config_dir, #copy_in_core_config_dir, #copy_in_project_config_dir, #parse_plugin_list_lines, #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_list_all_when_no_user_plugins_installed ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 109 def test_list_all_when_no_user_plugins_installed result = run_inspec_process_with_this_plugin("plugin list --all") skip_windows! assert_empty result.stderr plugins_seen = parse_plugin_list_lines(result.stdout) # Look for a specific plugin of each type - core, bundle, and system LIST_CASES.each do |test_case| plugin_line = plugins_seen.detect { |plugin| plugin[:name] == test_case[:name] } refute_nil plugin_line, "#{test_case[:name]} should be detected in plugin list --all output" assert_equal test_case[:type], plugin_line[:type], "#{test_case[:name]} should be detected as a '#{test_case[:type]}' type in list --all " end assert_exit_code 0, result end |
#test_list_selective_when_no_user_plugins_installed ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 125 def test_list_selective_when_no_user_plugins_installed LIST_CASES.each do |test_case| result = run_inspec_process_with_this_plugin("plugin list #{test_case[:arg]}") skip_windows! assert_empty result.stderr plugins_seen = parse_plugin_list_lines(result.stdout) plugin_line = plugins_seen.detect { |plugin| plugin[:name] == test_case[:name] } refute_nil plugin_line, "#{test_case[:name]} should be detected in plugin list #{test_case[:arg]} output" assert_equal plugin_line[:type], test_case[:type], "#{test_case[:name]} should be detected as a '#{test_case[:type]}' type in list #{test_case[:arg]} " assert_exit_code 0, result end end |
#test_list_when_a_train_plugin_is_installed ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 169 def test_list_when_a_train_plugin_is_installed 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("train-test-fixture", tmp_dir) end result = run_inspec_process_with_this_plugin("plugin list --user ", pre_run: pre_block) skip_windows! assert_empty result.stderr plugins_seen = parse_plugin_list_lines(result.stdout) assert_equal 1, plugins_seen.count assert_includes result.stdout, "1 plugin(s) total", "list train should show one plugins" # Plugin Name Version Via ApiVer # ------------------------------------------------------------- # train-test-fixture 0.1.0 gem (user) train-1 # ------------------------------------------------------------- # 1 plugin(s) total train_plugin = plugins_seen.detect { |p| p[:name] == "train-test-fixture" } refute_nil train_plugin assert_equal "gem (user)", train_plugin[:type] assert_equal "train-1", train_plugin[:generation] assert_equal "0.1.0", train_plugin[:version] assert_exit_code 0, result end |
#test_list_when_gem_and_path_plugins_installed ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 139 def test_list_when_gem_and_path_plugins_installed 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 result = run_inspec_process_with_this_plugin("plugin list --user ", pre_run: pre_block) skip_windows! assert_empty result.stderr plugins_seen = parse_plugin_list_lines(result.stdout) assert_equal 2, plugins_seen.count # Plugin Name Version Via ApiVer # --------------------------------------------------------- # inspec-meaning-of-life src path 2 # inspec-test-fixture 0.1.0 gem (user) 2 # --------------------------------------------------------- # 2 plugin(s) total meaning = plugins_seen.detect { |p| p[:name] == "inspec-meaning-of-life" } refute_nil meaning assert_equal "path", meaning[:type] fixture = plugins_seen.detect { |p| p[:name] == "inspec-test-fixture" } refute_nil fixture assert_equal "gem (user)", fixture[:type] assert_equal "0.1.0", fixture[:version] assert_exit_code 0, result end |