mirror of
https://github.com/inspec/inspec
synced 2024-12-19 17:43:44 +00:00
544204a44c
* Move inspec init to v2 plugins. * Revert inspec run command env change. * Allow prefix and env for run_inspec_process. * Update unit tests to use new functionality. Signed-off-by: Jared Quick <jquick@chef.io>
30 lines
1,022 B
Ruby
30 lines
1,022 B
Ruby
# encoding: utf-8
|
|
|
|
require_relative '../../../shared/core_plugin_test_helper.rb'
|
|
|
|
class InitCli < MiniTest::Test
|
|
include CorePluginFunctionalHelper
|
|
|
|
def test_generating_inspec_profile
|
|
Dir.mktmpdir do |dir|
|
|
profile = File.join(dir, 'test-profile')
|
|
out = run_inspec_process("init profile test-profile", prefix: "cd #{dir} &&")
|
|
assert_equal 0, out.exit_status
|
|
assert_includes out.stdout, 'Create new profile at'
|
|
assert_includes out.stdout, profile
|
|
assert_includes Dir.entries(profile).join, 'inspec.yml'
|
|
assert_includes Dir.entries(profile).join, 'README.md'
|
|
end
|
|
end
|
|
|
|
def test_profile_with_slash_name
|
|
Dir.mktmpdir do |dir|
|
|
profile = dir + '/test/deeper/profile'
|
|
out = run_inspec_process("init profile test/deeper/profile", prefix: "cd #{dir} &&")
|
|
assert_equal 0, out.exit_status
|
|
assert_equal true, File.exist?(profile)
|
|
profile = YAML.load_file("#{profile}/inspec.yml")
|
|
assert_equal 'profile', profile['name']
|
|
end
|
|
end
|
|
end
|