Class: PluginManagerCliDefinitionTests

Inherits:
Minitest::Test
  • Object
show all
Includes:
CorePluginUnitHelper
Defined in:
lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb

Overview

———————————————————————–# Plugin Definition ———————————————————————–#

Constant Summary collapse

@@orig_home =
Dir.home

Instance Method Summary collapse

Instance Method Details

#reset_globalsObject

TODO: REFACTOR this with install/loader tests



22
23
24
25
26
# File 'lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb', line 22

def reset_globals # TODO: REFACTOR this with install/loader tests
  ENV["HOME"] = @@orig_home
  ENV["INSPEC_CONFIG_DIR"] = nil
  Inspec::Plugin::V2::Registry.instance.__reset
end

#setupObject



11
12
13
14
15
16
# File 'lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb', line 11

def setup
  mock_path = File.expand_path "test/unit/mock"

  @config_dir_path = File.join(mock_path, "config_dirs")
  ENV["HOME"] = File.join(@config_dir_path, "fakehome")
end

#teardownObject



18
19
20
# File 'lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb', line 18

def teardown
  reset_globals
end

#test_plugin_registeredObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb', line 28

def test_plugin_registered
  loader = Inspec::Plugin::V2::Loader.new
  loader.load_all # We want to ensure it is auto-loaded

  assert registry.known_plugin?(:'inspec-plugin-manager-cli'), "inspec-plugin-manager-cli should be registered"
  assert registry.loaded_plugin?(:'inspec-plugin-manager-cli'), "inspec-plugin-manager-cli should be loaded"

  status = registry[:'inspec-plugin-manager-cli']
  assert_equal 2, status.api_generation, "inspec-plugin-manager-cli should be v2"
  assert_includes status.plugin_types, :cli_command, "inspec-plugin-manager-cli should have cli_command activators"
end