2019-06-11 22:24:35 +00:00
|
|
|
require_relative "../../../shared/core_plugin_test_helper.rb"
|
2018-09-25 14:29:18 +00:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------#
|
|
|
|
# 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
|
2019-11-09 03:08:20 +00:00
|
|
|
mock_path = File.expand_path "test/fixtures"
|
2019-05-17 00:47:54 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
@config_dir_path = File.join(mock_path, "config_dirs")
|
|
|
|
ENV["HOME"] = File.join(@config_dir_path, "fakehome")
|
2019-05-17 00:47:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
reset_globals
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_globals # TODO: REFACTOR this with install/loader tests
|
2019-06-11 22:24:35 +00:00
|
|
|
ENV["HOME"] = @@orig_home
|
|
|
|
ENV["INSPEC_CONFIG_DIR"] = nil
|
2019-05-17 00:47:54 +00:00
|
|
|
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
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
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"
|
2018-09-25 14:29:18 +00:00
|
|
|
|
|
|
|
status = registry[:'inspec-plugin-manager-cli']
|
2019-06-11 22:24:35 +00:00
|
|
|
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"
|
2018-09-25 14:29:18 +00:00
|
|
|
end
|
|
|
|
end
|