mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
add simple command tests for inspec check
This commit is contained in:
parent
e53d33bc98
commit
0a4567d49f
1 changed files with 44 additions and 0 deletions
44
test/functional/command_test.rb
Normal file
44
test/functional/command_test.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
require 'helper'
|
||||
require 'train'
|
||||
|
||||
describe 'Inspec::InspecCLI' do
|
||||
let(:runner) { Train.create('local').connection }
|
||||
let(:repo_path) { File.expand_path(File.join( __FILE__, '..', '..', '..')) }
|
||||
let(:exec_inspec) { File.join(repo_path, 'bin', 'inspec') }
|
||||
let(:profile_path) { File.join(repo_path, 'test', 'unit', 'mock', 'profiles') }
|
||||
let(:examples_path) { File.join(repo_path, 'examples') }
|
||||
|
||||
def inspec(commandline)
|
||||
runner.run_command("#{exec_inspec} #{commandline}")
|
||||
end
|
||||
|
||||
describe 'example profile' do
|
||||
let(:path) { File.join(examples_path, 'profile') }
|
||||
|
||||
it 'check is successful' do
|
||||
out = inspec('check ' + path)
|
||||
out.stdout.must_match /Valid.*true/
|
||||
out.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
|
||||
describe 'example inheritance profile' do
|
||||
let(:path) { File.join(examples_path, 'inheritance') }
|
||||
|
||||
it 'check fails without --profiles-path' do
|
||||
out = inspec('check ' + path)
|
||||
out.stderr.must_include 'You must supply a --profiles-path to inherit'
|
||||
out.exit_status.must_equal 1
|
||||
end
|
||||
|
||||
it 'check succeeds with --profiles-path' do
|
||||
out = inspec('check ' + path + ' --profiles-path ' + examples_path)
|
||||
out.stdout.must_match /Valid.*true/
|
||||
out.exit_status.must_equal 0
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue