Sha256: b1f5057c6378190bc40d36481976973f2da06f3e969237a9d93e9e0632a077ff

Contents?: true

Size: 1.9 KB

Versions: 7

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 pdef, %w[ in over done. ]

    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 => '1'
          echo 'done.'
        end
        sequence do
          wait '1s'
          echo 'over'
          set 'v:ok' => true
        end
      end
    end

    #noisy

    assert_trace pdef, %w[ in over done. ]

    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 pdef, %w[ in over done. ]

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

Version data entries

7 entries across 7 versions & 1 rubygems

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