Sha256: 0fe643be5cf7763049ce747d60f212c47dea206a3563337f2165af85e5b2d153

Contents?: true

Size: 1.87 KB

Versions: 122

Compression:

Stored size: 1.87 KB

Contents

require "helpers/test_helper"

test_name "dsl::helpers::host_helpers #run_script" do
  step "#run_script fails when the local script cannot be found" do
    assert_raises IOError do
      run_script "/non/existent/testfile.sh"
    end
  end

  step "#run_script fails when there is an error running the remote script" do
    Dir.mktmpdir do |local_dir|
      local_filename = File.join(local_dir, "testfile.sh")
      local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")

      assert_raises Beaker::Host::CommandFailure do
        run_script local_filename
      end
    end
  end

  step "#run_script passes along options when running the remote command" do
    Dir.mktmpdir do |local_dir|
      local_filename = File.join(local_dir, "testfile.sh")
      local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")

      result = run_script local_filename, { :accept_all_exit_codes => true }
      assert_equal 1, result.exit_code
    end
  end

  step "#run_script runs the script on the remote host" do
    Dir.mktmpdir do |local_dir|
      local_filename = File.join(local_dir, "testfile.sh")
      local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")

      results = run_script local_filename
      assert_equal 0, results.exit_code
      assert_equal "output\n", results.stdout
    end
  end

  step "#run_script allows assertions in an optional block" do
    Dir.mktmpdir do |local_dir|
      local_filename = File.join(local_dir, "testfile.sh")
      local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")

      results = run_script local_filename do
        assert_equal 0, exit_code
        assert_equal "output\n", stdout
      end
    end
  end
end

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
beaker-4.38.1 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.38.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.37.2 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.37.1 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.37.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.36.1 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.36.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.35.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.34.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.33.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.32.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.31.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.30.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.29.1 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.29.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.28.1 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.28.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.27.1 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.27.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb
beaker-4.26.0 acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb