From bfd88df27ad068f721f54076e664402ecbe4acc2 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 16 Mar 2016 19:29:55 +0100 Subject: [PATCH] verify that archive creates valid zip and tar files --- test/functional/command_test.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/functional/command_test.rb b/test/functional/command_test.rb index c74184e69..ff805894e 100644 --- a/test/functional/command_test.rb +++ b/test/functional/command_test.rb @@ -87,12 +87,28 @@ describe 'Inspec::InspecCLI' do x = rand.to_s File.write(dst.path, x) out = inspec('archive ' + path + ' --output ' + dst.path + ' --overwrite') - out.stderr.must_equal '' # uh... + out.stderr.must_equal '' out.stdout.must_include 'Generate archive '+dst.path out.exit_status.must_equal 0 File.read(dst.path).wont_equal x end + it 'creates valid tar.gz files' do + out = inspec('archive ' + path + ' --output ' + dst.path + ' --tar') + out.stderr.must_equal '' + out.stdout.must_include 'Generate archive '+dst.path + out.exit_status.must_equal 0 + t = Zlib::GzipReader.open(dst.path) + Gem::Package::TarReader.new(t).entries.map(&:header).map(&:name).must_include 'inspec.yml' + end + + it 'creates valid zip files' do + out = inspec('archive ' + path + ' --output ' + dst.path + ' --zip') + out.stderr.must_equal '' + out.stdout.must_include 'Generate archive '+dst.path + out.exit_status.must_equal 0 + Zip::File.new(dst.path).entries.map(&:name).must_include 'inspec.yml' + end end describe 'example inheritance profile' do