Sha256: bff287cf139a24f866f5c3c3be042e826d9a1a27fc084d5c647251d932de02c3

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

require File.dirname(__FILE__)+'/test_helper'

class ExecTest < Test::Unit::TestCase
  it 'success' do
    success_sh  = File.expand_path File.dirname(__FILE__)+"/success.sh"
    e = RSched::ExecRunner.new(success_sh)

    ident = 'ident'
    time = Time.parse("2010-02-02 00:00:00 UTC").to_i
    action = 'act'

    assert_nothing_raised do
      e.call(ident, time, action)
    end
  end

  it 'fail' do
    fail_sh  = File.expand_path File.dirname(__FILE__)+"/fail.sh"
    e = RSched::ExecRunner.new(fail_sh)

    ident = 'ident'
    time = Time.parse("2010-02-02 00:00:00 UTC").to_i
    action = 'act'

    assert_raise(RuntimeError) do
      e.call(ident, time, action)
    end
  end

  it 'stdin' do
    cat_sh  = File.expand_path File.dirname(__FILE__)+"/cat.sh"
    out_tmp = File.expand_path File.dirname(__FILE__)+"/cat.sh.tmp"
    e = RSched::ExecRunner.new("#{cat_sh} #{out_tmp}")

    ident = 'ident'
    time = Time.parse("2010-02-02 00:00:00 UTC").to_i
    action = 'act'

    e.call(ident, time, action)

    assert_equal [ident, time, action].join("\t"), File.read(out_tmp)
  end

  it 'huge' do
    huge_sh  = File.expand_path File.dirname(__FILE__)+"/huge.sh"
    e = RSched::ExecRunner.new("#{huge_sh}")

    ident = 'ident'
    time = Time.parse("2010-02-02 00:00:00 UTC").to_i
    action = 'act'

    e.call(ident, time, action)

    # should finish
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rsched-0.3.3 test/exec_test.rb
rsched-0.3.2 test/exec_test.rb
rsched-0.3.1 test/exec_test.rb
rsched-0.3.0 test/exec_test.rb
rsched-0.2.0 test/exec_test.rb