mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
Adopt the new UI style table, breaking most of the UI tests, which were already broken anyway
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
68329aa8e5
commit
8cab0e862b
2 changed files with 36 additions and 13 deletions
|
@ -20,17 +20,18 @@ module InspecPlugins
|
|||
plugin_statuses = Inspec::Plugin::V2::Registry.instance.plugin_statuses
|
||||
plugin_statuses.reject! { |s| %i{core bundle}.include?(s.installation_type) } unless options[:all]
|
||||
|
||||
puts
|
||||
ui.bold(format(" %-30s%-10s%-8s%-6s", "Plugin Name", "Version", "Via", "ApiVer"))
|
||||
ui.line
|
||||
plugin_statuses.sort_by(&:name).each do |status|
|
||||
ui.plain(format(" %-30s%-10s%-8s%-6s", status.name,
|
||||
make_pretty_version(status),
|
||||
make_pretty_install_type(status),
|
||||
status.api_generation.to_s))
|
||||
ui.table do |t|
|
||||
t.header = ["Plugin Name", "Version", "Via", "ApiVer"]
|
||||
plugin_statuses.map { |s| [s.name.to_s, s] }.sort { |sa, sb| sa[0] <=> sb[0] }.map { |sf| sf[1] }.each do |status|
|
||||
t << [
|
||||
status.name,
|
||||
make_pretty_version(status),
|
||||
make_pretty_install_type(status),
|
||||
status.api_generation,
|
||||
]
|
||||
end
|
||||
end
|
||||
ui.line
|
||||
ui.plain(" #{plugin_statuses.count} plugin(s) total")
|
||||
ui.plain_line(" #{plugin_statuses.count} plugin(s) total")
|
||||
puts
|
||||
end
|
||||
|
||||
|
|
|
@ -39,6 +39,26 @@ module PluginManagerHelpers
|
|||
end
|
||||
end
|
||||
|
||||
def parse_plugin_list_lines(stdout)
|
||||
plugins = []
|
||||
|
||||
stdout.force_encoding("UTF-8").lines.each do |line|
|
||||
next if line.include? "─────" # This is some unicode glyphiness
|
||||
next if line.include? "Plugin Name"
|
||||
next if line.include? "plugin(s) total"
|
||||
|
||||
parts = line.split(/│/u).map { |p| p.strip! }.compact
|
||||
plugins << {
|
||||
name: parts[0],
|
||||
version: parts[1],
|
||||
type: parts[2],
|
||||
generation: parts[3],
|
||||
raw: line,
|
||||
}
|
||||
end
|
||||
plugins
|
||||
end
|
||||
|
||||
def teardown
|
||||
clear_empty_config_dir
|
||||
end
|
||||
|
@ -88,7 +108,9 @@ class PluginManagerCliList < Minitest::Test
|
|||
def test_list_all_when_no_user_plugins_installed
|
||||
skip_windows!
|
||||
result = run_inspec_process_with_this_plugin("plugin list --all")
|
||||
plugin_lines = result.stdout.lines.filter { |line| line.match(/^\s*(inspec|train)-/) }
|
||||
assert_empty result.stderr
|
||||
|
||||
plugins_seen = parse_plugin_list_lines(result.stdout)
|
||||
|
||||
# Look for a specific plugin of each type - core, bundle, and system
|
||||
[
|
||||
|
@ -96,9 +118,9 @@ class PluginManagerCliList < Minitest::Test
|
|||
{ name: "inspec-supermarket", type: "bundle" },
|
||||
{ name: "train-aws", type: "gem (system)" },
|
||||
].each do |test_case|
|
||||
plugin_line = plugin_lines.detect { |line| line.include? test_case[:name] }
|
||||
plugin_line = plugins_seen.detect { |plugin| plugin[:name] == test_case[:name] }
|
||||
refute_nil plugin_line, "#{test_case[:name]} should be detected in plugin list --all output"
|
||||
assert_includes plugin_line, test_case[:type], "#{test_case[:name]} should be detected as a '#{test_case[:type]}' type in list --all "
|
||||
assert_equal plugin_line[:type], test_case[:type], "#{test_case[:name]} should be detected as a '#{test_case[:type]}' type in list --all "
|
||||
end
|
||||
assert_exit_code 0, result
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue