Sha256: 82f30059fe37df336c154c8ce259d1752555d10d9fb9263db95538fa59d025c3

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

#
# Testing Rufus
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#

require 'test/unit'
require 'openwfe/util/scheduler'

#
# testing otime and the scheduler
#

class Scheduler1Test < Test::Unit::TestCase

  #def setup
  #end

  #def teardown
  #end

  def test_0

    scheduler = Rufus::Scheduler.new
    scheduler.start

    job_id = scheduler.schedule_every "500", :tags => "Avery" do
      # don't do a thing
    end

    sleep 0.300

    count = nil

    200_000.times do |i|
      break if scheduler.get_job(job_id) == nil
      count = i + 1
    end

    scheduler.sstop

    assert_equal 200_000, count
  end

  def test_1

    scheduler = Rufus::Scheduler.start_new

    job_id = scheduler.schedule_every "500", :tags => "Avery" do
      # don't do a thing
    end

    sleep 0.300

    count = 1

    200_000.times do
      count = scheduler.find_jobs("Avery").size
      #p scheduler.instance_variable_get(:@non_cron_jobs).keys if count != 1
      break if count != 1
    end

    scheduler.sstop

    assert_equal 1, count
  end

  #
  # testing "deviation", if I may call it like that...
  #
  def _test_2

    scheduler = Rufus::Scheduler.start_new
    last = nil
    job_id = scheduler.schedule_every "1s" do
      t = Time.now
      puts t.to_f
    end
    sleep 4 * 60
    scheduler.sstop
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rufus-scheduler-1.0.10 test/scheduler_1_test.rb
rufus-scheduler-1.0.8 test/scheduler_1_test.rb
rufus-scheduler-1.0.11 test/scheduler_1_test.rb
rufus-scheduler-1.0.9 test/scheduler_1_test.rb