test/cron_test.rb in openwferu-0.9.15 vs test/cron_test.rb in openwferu-0.9.16

- old
+ new

@@ -22,11 +22,11 @@ #end #def teardown #end - def test_cron_0 + def test_0 $var = 0 scheduler = OpenWFE::Scheduler.new scheduler.start @@ -41,9 +41,64 @@ scheduler.stop #puts ">#{$var}<" assert_equal $var, 2, "$var should be at 2, it's at #{$var}" + end + + def test_1 + + scheduler = OpenWFE::Scheduler.new + scheduler.start + + sec = nil + has_gone_wrong = false + counter = 0 + + scheduler.schedule "* * * * * *" do + t = Time.new + if (t.sec == sec) + has_gone_wrong = true + #print "x" + else + #print "." + end + #STDOUT.flush + sec = t.sec + counter = counter + 1 + end + + sleep 10 + scheduler.stop + + assert_equal 10, counter + assert (not has_gone_wrong) + end + + def test_2 + + scheduler = OpenWFE::Scheduler.new + scheduler.start + + seen = false + has_gone_wrong = false + + scheduler.schedule "7 * * * * *" do + if seen + has_gone_wrong = true + #print "x" + else + seen = true + #print "." + end + #STDOUT.flush + end + + sleep 61 + scheduler.stop + + assert seen + assert (not has_gone_wrong) end protected class CounterSchedulable