Sha256: 20b370730f19ebc6e80cc945e2bff252b512131974e9100895ce180449156a8f

Contents?: true

Size: 1.78 KB

Versions: 52

Compression:

Stored size: 1.78 KB

Contents

require "helpers/test_helper"

test_name "dsl::helpers::host_helpers #scp_to" do
  step "#scp_to fails if the local file cannot be found" do
    remote_tmpdir = default.tmpdir()
    assert_raises IOError do
      scp_to default, "/non/existent/file.txt", remote_tmpdir
    end
  end

  if test_scp_error_on_close?
    step "#scp_to fails if the remote path cannot be found" do
      Dir.mktmpdir do |local_dir|
        local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")

        # assert_raises Beaker::Host::CommandFailure do
        assert_raises RuntimeError do
          scp_to default, local_filename, "/non/existent/remote/file.txt"
        end
      end
    end
  end

  step "#scp_to creates the file on the remote system" do
    Dir.mktmpdir do |local_dir|
      local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
      remote_tmpdir = default.tmpdir()

      scp_to default, local_filename, remote_tmpdir

      remote_filename = File.join(remote_tmpdir, "testfile.txt")
      remote_contents = on(default, "cat #{remote_filename}").stdout
      assert_equal contents, remote_contents
    end
  end

  step "#scp_to creates the file on all remote systems when a host array is provided" do
    Dir.mktmpdir do |local_dir|
      local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")

      remote_tmpdir = default.tmpdir()
      on hosts, "mkdir -p #{remote_tmpdir}"
      remote_filename = File.join(remote_tmpdir, "testfile.txt")

      scp_to hosts, local_filename, remote_tmpdir

      hosts.each do |host|
        remote_contents = on(host, "cat #{remote_filename}").stdout
        assert_equal contents, remote_contents
      end
    end
  end

end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
beaker-4.25.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.24.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.23.2 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.23.1 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.23.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.22.1 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.22.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.21.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.20.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.19.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.18.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.17.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.16.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.15.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.14.1 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.14.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.13.1 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.13.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.12.0 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
beaker-4.11.1 acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb