From 826c9fd4c894d93cc3234520dda1754b6f18e77c Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Wed, 30 Nov 2016 00:12:47 +0100 Subject: [PATCH] add functional tests for tar lockfile reading Signed-off-by: Christoph Hartmann --- test/functional/inspec_vendor_test.rb | 41 ++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/test/functional/inspec_vendor_test.rb b/test/functional/inspec_vendor_test.rb index a39d7830e..a04338a24 100644 --- a/test/functional/inspec_vendor_test.rb +++ b/test/functional/inspec_vendor_test.rb @@ -22,7 +22,10 @@ describe 'example inheritance profile' do it 'can vendor profile dependencies from the profile path' do # clean existing vendor directory - FileUtils.rm_r ("#{inheritance_path}/vendor") + begin + FileUtils.rm_r ("#{inheritance_path}/vendor") + rescue Errno::ENOENT => e + end # vendor all dependencies out = inspec('vendor --overwrite', "cd #{inheritance_path} &&") @@ -39,7 +42,10 @@ describe 'example inheritance profile' do it 'ensure nothing is loaded from external source if vendored profile is used' do # clean existing vendor directory - FileUtils.rm_r ("#{meta_path}/vendor") + begin + FileUtils.rm_r ("#{meta_path}/vendor") + rescue Errno::ENOENT => e + end # vendor all dependencies out = inspec('vendor ' + meta_path + ' --overwrite') @@ -66,7 +72,10 @@ describe 'example inheritance profile' do out = inspec('vendor ' + meta_path + ' --overwrite') # clean cache directory - FileUtils.rm_rf "#{Dir.home}/.inspec/cache" + begin + FileUtils.rm_rf "#{Dir.home}/.inspec/cache" + rescue Errno::ENOENT => e + end # execute json command out = inspec('json ' + meta_path + ' -l debug') @@ -84,7 +93,10 @@ describe 'example inheritance profile' do out = inspec('vendor ' + meta_path + ' --overwrite') # clean cache directory - FileUtils.rm_rf "#{Dir.home}/.inspec/cache" + begin + FileUtils.rm_rf "#{Dir.home}/.inspec/cache" + rescue Errno::ENOENT => e + end # execute check command out = inspec('check ' + meta_path + ' -l debug') @@ -116,4 +128,25 @@ describe 'example inheritance profile' do lockfile = File.join(inheritance_path, 'inspec.lock') File.exist?(lockfile).must_equal true end + + it 'use lockfile in tarball' do + # ensure the profile is vendored and packaged as tar + out = inspec('vendor ' + meta_path + ' --overwrite') + out.exit_status.must_equal 0 + out = inspec('archive ' + meta_path + ' --overwrite') + out.exit_status.must_equal 0 + + # clean cache directory + begin + FileUtils.rm_rf "#{Dir.home}/.inspec/cache" + rescue Errno::ENOENT => e + end + + # execute json command + out = inspec(' meta-profile.tar.gz -l debug') + out.exit_status.must_equal 0 + + length = out.stdout.scan(/Fetching URL:/).length + length.must_equal 0 + end end