2018-09-25 14:29:18 +00:00
|
|
|
require_relative '../../../shared/core_plugin_test_helper.rb'
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------#
|
|
|
|
# Plugin Definition
|
|
|
|
#-----------------------------------------------------------------------#
|
2019-04-24 00:21:31 +00:00
|
|
|
class PluginManagerCliDefinitionTests < Minitest::Test
|
2018-09-25 14:29:18 +00:00
|
|
|
include CorePluginUnitHelper
|
|
|
|
|
2019-05-17 00:47:54 +00:00
|
|
|
@@orig_home = Dir.home
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
reset_globals
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-09-25 14:29:18 +00:00
|
|
|
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
|
|
|
|
end
|