2016-02-05 11:40:57 +00:00
|
|
|
# author: Christoph Hartmann
|
|
|
|
# author: Dominik Richter
|
|
|
|
|
2016-02-05 15:57:51 +00:00
|
|
|
# TODO: do not use helper, since all plugins are loaded statically
|
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'mocha/setup'
|
|
|
|
|
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 22:16:32 +00:00
|
|
|
require 'inspec/plugin/v1/plugin_types/cli'
|
2016-02-05 11:40:57 +00:00
|
|
|
require 'thor'
|
|
|
|
|
|
|
|
describe 'plugin system' do
|
|
|
|
describe 'with an empty profile' do
|
|
|
|
let(:cli_reg) { Inspec::Plugins::CLI }
|
|
|
|
|
2016-02-05 15:57:51 +00:00
|
|
|
before do
|
2016-02-08 21:25:07 +00:00
|
|
|
# since the registry is a global singleton, clean it before using
|
|
|
|
cli_reg.subcommands.clear
|
2016-02-05 15:57:51 +00:00
|
|
|
end
|
|
|
|
|
2016-02-05 11:40:57 +00:00
|
|
|
it 'is empty' do
|
2016-02-08 21:25:07 +00:00
|
|
|
cli_reg.subcommands.must_equal({})
|
2016-02-05 11:40:57 +00:00
|
|
|
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 }
|
|
|
|
}
|
2016-02-08 21:25:07 +00:00
|
|
|
cli_reg.add_subcommand(
|
2016-02-05 11:40:57 +00:00
|
|
|
plugin[:klass],
|
|
|
|
plugin[:subcommand_name],
|
|
|
|
plugin[:usage],
|
|
|
|
plugin[:description],
|
|
|
|
plugin[:options]
|
|
|
|
)
|
2016-02-08 21:25:07 +00:00
|
|
|
cli_reg.subcommands['my_cmd'].must_equal(plugin)
|
2016-02-05 11:40:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|