Sha256: 51ffe9d5626de1677e2251a82721da636951c36f26a34c7e11e27739babfaac2

Contents?: true

Size: 1.51 KB

Versions: 7

Compression:

Stored size: 1.51 KB

Contents

#
# testing ruote
#
# Thu Jun 18 11:03:45 JST 2009
#

require File.join(File.dirname(__FILE__), 'base')


class EftWaitTest < Test::Unit::TestCase
  include FunctionalBase

  def test_wait_for

    pdef = Ruote.process_definition do
      sequence do
        alpha
        wait :for => '2s'
        alpha
        echo 'done.'
      end
    end

    #noisy

    ts = []
    @engine.register_participant(:alpha) { ts << Time.now }

    assert_trace pdef, 'done.'

    #p [ ts[1].sec, ts[0].sec ]
    assert [ 2, 3 ].include?((ts[1].sec - ts[0].sec) % 60)
  end

  def test_cancel_wait

    pdef = Ruote.process_definition do
      sequence do
        echo 'a'
        wait :for => '3d'
        echo 'b'
      end
    end

    #noisy

    wfid = @engine.launch(pdef)

    wait_for(4)

    @engine.cancel_process(wfid)

    wait_for(wfid)

    assert_equal 'a', @tracer.to_s
    assert_equal 0, @engine.storage.get_many('schedules').size
  end

  def test_wait_until

    pdef = Ruote.process_definition do
      sequence do
        alpha
        wait :until => (Time.now + 2.0).to_s
        alpha
        echo 'done.'
      end
    end

    #noisy

    ts = []
    @engine.register_participant(:alpha) { ts << Time.now }

    assert_trace pdef, 'done.'

    #p ts
    assert ts[1] - ts[0] > 1.0, "#{ts[1] - ts[0]} should be > 1.0"
  end

  def test_wait_until_now

    pdef = Ruote.process_definition do
      sequence do
        echo 'a'
        wait Time.now
        echo 'b'
      end
    end

    #noisy

    assert_trace pdef, %w[ a b ]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruote-2.1.7 test/functional/eft_11_wait.rb
ruote-2.1.6 test/functional/eft_11_wait.rb
ruote-2.1.5 test/functional/eft_11_wait.rb
ruote-2.1.4 test/functional/eft_11_wait.rb
ruote-2.1.3 test/functional/eft_11_wait.rb
ruote-2.1.2 test/functional/eft_11_wait.rb
ruote-2.1.1 test/functional/eft_11_wait.rb