Sha256: 04576d8c510d4f738454ebab76df13f857c3ebbf5d30b66ad79f349f0bf492ba
Contents?: true
Size: 1.81 KB
Versions: 13
Compression:
Stored size: 1.81 KB
Contents
require "helpers/test_helper" test_name "dsl::helpers::host_helpers #archive_file_from" do step "archiveroot parameter defaults to `archive/sut-files`" do # Create a remote file to archive filepath = default.tmpfile('archive-file-test') create_remote_file(default, filepath, 'contents ignored') # Prepare cleanup so we don't pollute the local filesystem teardown do FileUtils.rm_rf('archive') if Dir.exist?('archive') end # Test that the archiveroot default directory is created assert_equal(false, Dir.exist?('archive')) assert_equal(false, Dir.exist?('archive/sut-files')) archive_file_from(default, filepath) assert_equal(true, Dir.exist?('archive/sut-files')) end step "fails archive_file_from when from_path is non-existant" do # beaker-docker can't deal with closing the connection confine :except, :hypervisor => 'docker' filepath = "foo-filepath-should-not-exist" assert_raises IOError do archive_file_from(default, filepath) end end step "archive is copied to local <archiveroot>/<hostname>/<filepath> directory" do # Create a remote file to archive filepath = default.tmpfile('archive-file-test') create_remote_file(default, filepath, 'number of the beast') assert_equal(false, Dir.exist?(filepath)) # Test that the file is copied locally to <archiveroot>/<hostname>/<filepath> Dir.mktmpdir do |tmpdir| tar_path = File.join(tmpdir, default, filepath + '.tgz') archive_file_from(default, filepath, {}, tmpdir, tar_path) assert_path_exists(tar_path) expected_path = File.join(tmpdir, default) tgz = Zlib::GzipReader.new(File.open(tar_path, 'rb')) Minitar.unpack(tgz, expected_path) assert_equal('number of the beast', File.read(expected_path + '/' + filepath).strip) end end end
Version data entries
13 entries across 13 versions & 1 rubygems