2020-12-18 16:49:35 +00:00
|
|
|
require_relative "../../../shared/core_plugin_test_helper"
|
|
|
|
require "fileutils" unless defined?(FileUtils)
|
2019-02-07 06:43:50 +00:00
|
|
|
|
2019-04-24 00:21:31 +00:00
|
|
|
class ProfileCli < Minitest::Test
|
2019-02-07 06:43:50 +00:00
|
|
|
include CorePluginFunctionalHelper
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@tmpdir = Dir.mktmpdir
|
2019-06-11 22:24:35 +00:00
|
|
|
@habitat_profile = File.join(@tmpdir, "habitat-profile")
|
|
|
|
run_inspec_process("init profile " + @habitat_profile)
|
2019-02-07 06:43:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
FileUtils.remove_entry_secure(@tmpdir)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_setup_subcommand
|
2019-06-11 22:24:35 +00:00
|
|
|
result = run_inspec_process("habitat profile setup " + @habitat_profile + " --log-level debug")
|
2019-02-07 06:43:50 +00:00
|
|
|
|
|
|
|
# Command creates only expected files
|
2019-06-11 22:24:35 +00:00
|
|
|
base_dir = File.join(@tmpdir, "habitat-profile", "habitat")
|
2019-02-07 06:43:50 +00:00
|
|
|
files = %w{
|
|
|
|
plan.sh
|
|
|
|
}
|
2019-06-11 22:24:35 +00:00
|
|
|
actual_files = Dir.glob(File.join(base_dir, "**/*"))
|
2019-02-07 06:43:50 +00:00
|
|
|
expected_files = files.map { |x| File.join(base_dir, x) }
|
|
|
|
assert_equal actual_files.sort, expected_files.sort
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
# Command runs without error
|
|
|
|
assert_empty result.stderr
|
|
|
|
|
|
|
|
assert_exit_code 0, result
|
2019-02-07 06:43:50 +00:00
|
|
|
end
|
|
|
|
end
|