Class: PluginManagerCliSearch

Inherits:
MiniTest::Test
  • Object
show all
Includes:
CorePluginFunctionalHelper, PluginManagerHelpers
Defined in:
lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb

Overview

—————————————————————————————–#

inspec plugin search

—————————————————————————————–#

Constant Summary

Constants included from CorePluginFunctionalHelper

CorePluginFunctionalHelper::TRAIN_CONNECTION

Instance Method Summary collapse

Methods included from PluginManagerHelpers

#clear_empty_config_dir, #copy_in_core_config_dir, #copy_in_project_config_dir, #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_search_for_a_gem_that_does_not_existObject



203
204
205
206
207
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 203

def test_search_for_a_gem_that_does_not_exist
  result = run_inspec_process('plugin search inspec-test-fixture-nonesuch')
  assert_equal 2, result.exit_status, 'Search should exit 2 on a miss'
  assert_includes result.stdout, '0 plugin(s) found', 'Search result should find 0 plugins'
end

#test_search_for_a_gem_with_missing_prefixObject



197
198
199
200
201
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 197

def test_search_for_a_gem_with_missing_prefix
  result = run_inspec_process('plugin search test-fixture')
  assert_equal 1, result.exit_status, 'Search should exit 1 on user error'
  assert_includes result.stdout, "All inspec plugins must begin with either 'inspec-' or 'train-'"
end

#test_search_for_a_real_gem_with_full_name_and_all_optionObject



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 184

def test_search_for_a_real_gem_with_full_name_and_all_option
  result = run_inspec_process('plugin search --all inspec-test-fixture')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
  assert_includes result.stdout, 'inspec-test-fixture', 'Search result should contain the gem name'
  assert_includes result.stdout, '1 plugin(s) found', 'Search result should find 1 plugin'

  line = result.stdout.split("\n").grep(/inspec-test-fixture/).first
  assert_match(/\s*inspec-test-fixture\s+\((\d+\.\d+\.\d+(,\s)?){2,}\)/,line,'Plugin line should include name and at least two versions')

  result = run_inspec_process('plugin search -a inspec-test-fixture')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
end

#test_search_for_a_real_gem_with_full_name_and_exact_optionObject



165
166
167
168
169
170
171
172
173
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 165

def test_search_for_a_real_gem_with_full_name_and_exact_option
  result = run_inspec_process('plugin search --exact inspec-test-fixture')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
  assert_includes result.stdout, 'inspec-test-fixture', 'Search result should contain the gem name'
  assert_includes result.stdout, '1 plugin(s) found', 'Search result should find 1 plugin'

  result = run_inspec_process('plugin search -e inspec-test-fixture')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
end

#test_search_for_a_real_gem_with_full_name_no_optionsObject



146
147
148
149
150
151
152
153
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 146

def test_search_for_a_real_gem_with_full_name_no_options
  result = run_inspec_process('plugin search inspec-test-fixture')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
  assert_includes result.stdout, 'inspec-test-fixture', 'Search result should contain the gem name'
  assert_includes result.stdout, '1 plugin(s) found', 'Search result should find 1 plugin'
  line = result.stdout.split("\n").grep(/inspec-test-fixture/).first
  assert_match(/\s*inspec-test-fixture\s+\((\d+\.\d+\.\d+){1}\)/,line,'Plugin line should include name and exactly one version')
end

#test_search_for_a_real_gem_with_full_name_no_options_and_train_nameObject



209
210
211
212
213
214
215
216
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 209

def test_search_for_a_real_gem_with_full_name_no_options_and_train_name
  result = run_inspec_process('plugin search train-test-fixture')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
  assert_includes result.stdout, 'train-test-fixture', 'Search result should contain the gem name'
  assert_includes result.stdout, '1 plugin(s) found', 'Search result should find 1 plugin'
  line = result.stdout.split("\n").grep(/train-test-fixture/).first
  assert_match(/\s*train-test-fixture\s+\((\d+\.\d+\.\d+){1}\)/,line,'Plugin line should include name and exactly one version')
end

#test_search_for_a_real_gem_with_stub_name_and_exact_optionObject



175
176
177
178
179
180
181
182
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 175

def test_search_for_a_real_gem_with_stub_name_and_exact_option
  result = run_inspec_process('plugin search --exact inspec-test-')
  assert_equal 2, result.exit_status, 'Search should exit 2 on a miss'
  assert_includes result.stdout, '0 plugin(s) found', 'Search result should find 0 plugins'

  result = run_inspec_process('plugin search -e inspec-test-')
  assert_equal 2, result.exit_status, 'Search should exit 2 on a miss'
end

#test_search_for_a_real_gem_with_stub_name_no_optionsObject



155
156
157
158
159
160
161
162
163
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 155

def test_search_for_a_real_gem_with_stub_name_no_options
  result = run_inspec_process('plugin search inspec-test-')
  assert_equal 0, result.exit_status, 'Search should exit 0 on a hit'
  assert_includes result.stdout, 'inspec-test-fixture', 'Search result should contain the gem name'
  assert_includes result.stdout, '1 plugin(s) found', 'Search result should find 1 plugin'

  line = result.stdout.split("\n").grep(/inspec-test-fixture/).first
  assert_match(/\s*inspec-test-fixture\s+\((\d+\.\d+\.\d+){1}\)/,line,'Plugin line should include name and exactly one version')
end