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

Version Path
beaker-6.4.1 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-6.4.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-6.3.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-6.2.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-6.1.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.8.1 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.8.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.7.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.6.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.5.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.4.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.3.1 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb
beaker-5.3.0 acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb