Sha256: 901a14ef41f7210bc17a5c900b66352cd805002480d62aa477b441028d0fa003

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

#
# testing ruote
#
# Mon Oct 26 17:49:55 JST 2009
#
# in the train from Friboug to Zurich-Flughafen
#

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


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

  def test_when

    pdef = Ruote.process_definition do
      echo 'in'
      concurrence do
        _when '${v:ok}', :freq => '1s' do
          echo 'done.'
        end
        sequence do
          wait '1s'
          echo 'over'
          set 'v:ok' => true
        end
      end
    end

    #noisy

    assert_trace %w[ in over done. ], pdef

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

  def test_when_blocking

    pdef = Ruote.process_definition do
      echo 'in'
      concurrence do
        sequence do
          _when '${v:ok}', :freq => '1s'
          echo 'done.'
        end
        sequence do
          wait '1s'
          echo 'over'
          set 'v:ok' => true
        end
      end
    end

    #noisy

    assert_trace %w[ in over done. ], pdef

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

  def test_cancel

    pdef = Ruote.process_definition do
      _when '${v:ok}', :freq => '10d'
      echo 'done.'
    end

    #noisy

    wfid = @engine.launch(pdef)

    wait_for(2)

    assert_equal 1, @engine.storage.get_many('schedules').size

    @engine.cancel_process(wfid)

    wait_for(4)

    assert_nil @engine.process(wfid)
    assert_equal 0, @engine.storage.get_many('schedules').size
  end

  def test_when_cron

    pdef = Ruote.process_definition do
      echo 'in'
      concurrence do
        _when '${v:ok}', :freq => '* * * * * *' do # every second
          echo 'done.'
        end
        sequence do
          wait '1s'
          echo 'over'
          set 'v:ok' => true
        end
      end
    end

    #noisy

    assert_trace %w[ in over done. ], pdef

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruote-2.1.11 test/functional/eft_28_when.rb
ruote-2.1.10 test/functional/eft_28_when.rb
ruote-2.1.9 test/functional/eft_28_when.rb
ruote-2.1.8 test/functional/eft_28_when.rb