Skip to content

Commit 3fff9f8

Browse files
committed
Test qrontab with timezones
1 parent 5d8a29d commit 3fff9f8

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

test/qron_test.rb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
test 'it schedules' do
1212

13-
File.open('test/qrontab', 'wb') do |f|
13+
File.open('test/qrontab', 'wb') { |f|
1414
f.write(%{
1515
* * * * * * $seen = true
16-
})
17-
end
16+
}) }
1817

1918
$seen = false
2019

@@ -33,11 +32,10 @@
3332

3433
test 'it schedules @reboot' do
3534

36-
File.open('test/qrontab', 'wb') do |f|
35+
File.open('test/qrontab', 'wb') { |f|
3736
f.write(%{
3837
@reboot $booted = true
39-
})
40-
end
38+
}) }
4139

4240
$booted = false
4341

@@ -53,5 +51,25 @@
5351

5452
assert q.started, nil
5553
end
54+
55+
test 'it schedules with a timezone' do
56+
57+
File.open('test/qrontab', 'wb') { |f|
58+
f.write(%{
59+
* * * * * $a << 'five'
60+
* * * * * * $a << 'six'
61+
* * * * * Asia/Tokyo $a << ctx[:cron].timezone.name
62+
* * * * * * Europe/Budapest $a << ctx[:cron].timezone.name
63+
}) }
64+
65+
$a = []
66+
67+
q = Qron.new(tab: 'test/qrontab')
68+
69+
sleep 2.1
70+
71+
assert $a.count { |e| e == 'six' } > 1
72+
assert $a.count { |e| e == 'Europe/Budapest' } > 1
73+
end
5674
end
5775

0 commit comments

Comments
 (0)