Merge pull request #478 from chef/sr/fix-tests

fix windows tests
This commit is contained in:
Christoph Hartmann 2016-02-22 14:49:39 +01:00
commit 3541836e8b
2 changed files with 6 additions and 12 deletions

View file

@ -17,6 +17,7 @@ end
require 'fileutils'
require 'pathname'
require 'tempfile'
require 'tmpdir'
require 'zip'
require 'utils/base_cli'
@ -51,8 +52,6 @@ class MockLoader
undefined: { family: nil, release: nil, arch: nil },
}
@archives = {}
# pass the os identifier to emulate a specific operating system
def initialize(os = nil)
# selects operating system
@ -266,9 +265,7 @@ class MockLoader
def self.profile_tgz(name)
path = File.join(home, 'mock', 'profiles', name)
archive = Tempfile.new([name, '.tar.gz'])
dst = archive.path
archive.close
dst = File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(name, '.tar.gz'))
# generate relative paths
files = Dir.glob("#{path}/**/*")
@ -277,16 +274,13 @@ class MockLoader
require 'inspec/archive/tar'
tag = Inspec::Archive::TarArchiveGenerator.new
tag.archive(path, relatives, dst)
@archives[dst] = archive
dst
end
def self.profile_zip(name, opts = {})
path = File.join(home, 'mock', 'profiles', name)
archive = Tempfile.new([name, '.zip'])
dst = archive.path
archive.close
dst = File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname(name, '.zip'))
# rubyzip only works relative paths
files = Dir.glob("#{path}/**/*")
@ -295,7 +289,7 @@ class MockLoader
require 'inspec/archive/zip'
zag = Inspec::Archive::ZipArchiveGenerator.new
zag.archive(path, relatives, dst)
@archives[dst] = archive
dst
end
end

View file

@ -82,7 +82,7 @@ describe Fetchers::Url do
let(:res) {
mock_open = Minitest::Mock.new
mock_open.expect :meta, {'content-type' => 'application/gzip'}
mock_open.expect :read, File.read(mock_file)
mock_open.expect :read, File.open(mock_file, 'rb').read
fetcher.expects(:open).returns(mock_open)
fetcher.resolve(target)
}
@ -115,7 +115,7 @@ describe Fetchers::Url do
let(:res) {
mock_open = Minitest::Mock.new
mock_open.expect :meta, {'content-type' => 'application/zip'}
mock_open.expect :read, File.read(mock_file)
mock_open.expect :read, File.open(mock_file, 'rb').read
fetcher.expects(:open).returns(mock_open)
fetcher.resolve(target)
}