test/scheduler_test.rb in openwferu-0.9.10.653 vs test/scheduler_test.rb in openwferu-0.9.11

- old
+ new

@@ -28,11 +28,11 @@ $var = nil scheduler = OpenWFE::Scheduler.new() scheduler.sstart - sid = scheduler.schedule_in('2s', TestSchedulable.new, nil) + sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new) assert \ sid, "scheduler_0 did not return a job id" @@ -142,11 +142,12 @@ # # phase 1 es = EverySchedulable.new - job_id = scheduler.schedule_every("500", es, nil) + job_id = scheduler.schedule_every("500", es) + #job_id = scheduler.schedule_every("500", :schedulable => es) sleep(3.2) assert_equal es.count, 6 @@ -178,9 +179,37 @@ end assert touched scheduler.sstop + end + + # + # Testing to see if a second job with the same id discards the first one. + # + def test_scheduler_6 + + scheduler = OpenWFE::Scheduler.new() + scheduler.start + + value = nil + + scheduler.schedule_in "3s", :job_id => "job" do + value = 0 + end + scheduler.schedule_in "2s", :job_id => "job" do + value = 1 + end + + sleep 2.5 + + assert_equal value, 1 + + sleep 4 + + assert_equal value, 1 + + scheduler.stop end protected class TestSchedulable