inspec/test/unit/plugin/v1/plugin_test.rb
Clinton Wolfe 811318f2f8 Plugins API v2: Loader, Base API, and Test Harness (#3278)
* Functional tests for userdir option
* Accepts --config-dir CLI option
* Actually loads a config file from the config dir, more cases to test
* Able to load config and verify contents from config-dir
* Functional tests to ensure precedence for config options
* Enable setting config dir via env var
* .inspec, not .inspec.d
* Begin converting PluginCtl to PluginLoader/Registry
* Able to load and partially validate the plugins.json file
* More work on the plugin loader
* Break the world, move next gen stuff to plugin/
* Be sure to require base cli in bundled plugins
* Move test file
* Revert changes to v1 plugin, so we can have a separate one
* Checkpoint commit
* Move v2 plugin work to v2 area
* Move plugins v1 code into an isolated directory
* rubocop fixes
* Rip out the stuff about a user-dir config file, just use a plugin file
* Two psuedocode test file
* Working base API, moock plugin type, and loader.
* Adjust load path to be more welcoming
* Silence circular depencency warning, which was breaking a unit test
* Linting
* Fix plugin type registry, add tests to cover
* Feedback from Jerry

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2018-08-16 18:16:32 -04:00

44 lines
1 KiB
Ruby

# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
# TODO: do not use helper, since all plugins are loaded statically
require 'minitest/autorun'
require 'minitest/spec'
require 'mocha/setup'
require 'inspec/plugin/v1/plugin_types/cli'
require 'thor'
describe 'plugin system' do
describe 'with an empty profile' do
let(:cli_reg) { Inspec::Plugins::CLI }
before do
# since the registry is a global singleton, clean it before using
cli_reg.subcommands.clear
end
it 'is empty' do
cli_reg.subcommands.must_equal({})
end
it 'stores one cli plugin' do
plugin = {
klass: Thor.new,
subcommand_name: 'my_cmd',
usage: 'usage my_cmd',
description: 'desc of my_cmd',
options: { test: 1 }
}
cli_reg.add_subcommand(
plugin[:klass],
plugin[:subcommand_name],
plugin[:usage],
plugin[:description],
plugin[:options]
)
cli_reg.subcommands['my_cmd'].must_equal(plugin)
end
end
end