Sha256: a7c918edf93f4955d89aadd5451d2fa1b172e6bcc44b9949017c99e96c3cdcec

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

#
# testing ruote
#
# Tue Jan  5 17:51:10 JST 2010
#

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

require 'ruote/log/fs_history'
require 'ruote/part/no_op_participant'


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

  def test_by_wfid

    pdef = Ruote.process_definition do
      alpha
      echo 'done.'
    end

    history = @engine.add_service(
      'history', 'ruote/log/storage_history', 'Ruote::StorageHistory')

    @engine.register_participant :alpha, Ruote::NoOpParticipant

    #noisy

    wfid0 = assert_trace(pdef, "done.")
    wfid1 = assert_trace(pdef, "done.\ndone.")

    sleep 0.100

    assert_equal 17, @engine.storage.get_many('history').size

    h = @engine.context.history.by_process(wfid0)
    #h.each { |r| p r }
    assert_equal 8, h.size

    # testing record.to_h

    h = @engine.context.history.by_process(wfid1)
    #h.each { |r| p r }
    assert_equal 8, h.size

    history.clear!

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

  def test_by_date

    @engine.add_service(
      'history', 'ruote/log/storage_history', 'Ruote::StorageHistory')

    6.times do |i|
      @engine.storage.put(
        '_id' => "!2010-01-06!11414#{i}!0!!20100106-bichisosupo",
        'type' => 'history')
    end
    7.times do |i|
      @engine.storage.put(
        '_id' => "!2010-01-07!11414#{i}!0!!20100107-bichitehoni",
        'type' => 'history')
    end

    assert_equal 6, @engine.context.history.by_date('2010-01-06').size
    assert_equal 7, @engine.context.history.by_date('2010-01-07').size
  end

  def test_range

    @engine.add_service(
      'history', 'ruote/log/storage_history', 'Ruote::StorageHistory')

    7.times do |i|
      i = i + 1
      @engine.storage.put(
        '_id' => "!2010-01-0#{i}!114147!0!!2010010#{i}-bichisosupo",
        'type' => 'history')
    end

    assert_equal(
      [ Time.parse('2010-01-01 00:00:00 UTC'),
        Time.parse('2010-01-08 00:00:00 UTC') ],
      @engine.context.history.range)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-2.1.7 test/functional/ft_36_storage_history.rb