Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 282 lines (253 sloc) 9.51 kb
a024e4a0 »
2008-06-19 reorganize test files
1 require File.join(File.dirname(__FILE__) + "/..","bdrb_test_helper")
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
2
a024e4a0 »
2008-06-19 reorganize test files
3 context "Cront Trigger in general" do
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
4 specify "should let tasks running at given time interval run" do
5 # every 5 seconds
6 a = BackgrounDRb::CronTrigger.new("*/5 * * * * * *")
7 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
8 firetime = a.fire_after_time(t_time)
9 firetime.min.should == 53
10 firetime.sec.should == 45
11 firetime.hour.should == 20
a024e4a0 »
2008-06-19 reorganize test files
12
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
13 # 5 minute of every hour
14 a = BackgrounDRb::CronTrigger.new("0 5 * * * * *")
15 firetime = a.fire_after_time(t_time)
16 firetime.sec.should == 0
17 firetime.min.should == 5
18 firetime.hour.should == 21
19 firetime.day.should == 13
a024e4a0 »
2008-06-19 reorganize test files
20
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
21 # every 5 minute
22 a = BackgrounDRb::CronTrigger.new("0 */5 * * * * *")
23 firetime = a.fire_after_time(t_time)
24 firetime.sec.should == 0
25 firetime.min.should == 55
26 firetime.hour.should == 20
27 firetime.day.should == 13
a024e4a0 »
2008-06-19 reorganize test files
28
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
29 # every 5 AM of every day
30 a = BackgrounDRb::CronTrigger.new("0 0 5 * * * *")
31 firetime = a.fire_after_time(t_time)
32 firetime.hour.should == 5
33 firetime.min.should == 0
34 firetime.sec.should == 0
35 firetime.day.should == 14
36 firetime.month.should == 2
c77502ca »
2008-02-13 updated the cron trigger and fixes related to handling increments in …
37
38 a = BackgrounDRb::CronTrigger.new("*/10 * * * * * ")
39 t_time = Time.parse("Wed Feb 13 23:17:55 +0530 2008")
40 firetime = a.fire_after_time(t_time)
41 firetime.hour.should == 23
42 firetime.min.should == 18
43 firetime.sec.should == 0
44 firetime.day.should == 13
45 firetime.month.should == 2
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
46 end
a024e4a0 »
2008-06-19 reorganize test files
47
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
48 specify "should return correct firetime for hour intervals" do
49 # every 5 hour
50 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
51 a = BackgrounDRb::CronTrigger.new("0 0 */5 * * * *")
52 firetime = a.fire_after_time(t_time)
53 firetime.hour.should == 0
54 firetime.min.should == 0
55 firetime.sec.should == 0
56 firetime.day.should == 14
57 firetime.month.should == 2
58 end
59
60 specify "should return firetime based on wday restriction" do
61 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
62 # on sunday and monday it should run every 5 th hour
63 a = BackgrounDRb::CronTrigger.new("0 0 */5 * * 0-1 *")
64 firetime = a.fire_after_time(t_time)
65 firetime.hour.should == 0
66 firetime.min.should == 0
67 firetime.sec.should == 0
68 firetime.day.should == 17
69 firetime.month.should == 2
a024e4a0 »
2008-06-19 reorganize test files
70
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
71 t_time2 = Time.parse("Sun Feb 17 20:53:43 +0530 2008")
72 firetime = a.fire_after_time(t_time2)
73 firetime.hour.should == 0
74 firetime.min.should == 0
75 firetime.sec.should == 0
76 firetime.day.should == 18
77 firetime.month.should == 2
a024e4a0 »
2008-06-19 reorganize test files
78
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
79 end
a024e4a0 »
2008-06-19 reorganize test files
80
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
81 specify "should wrap to next week for wday restirctions" do
82 a = BackgrounDRb::CronTrigger.new("0 0 */5 * * 0-1 *")
83 t_time = Time.parse("Mon Feb 18 20:53:43 +0530 2008")
84 firetime = a.fire_after_time(t_time)
85 firetime.hour.should == 0
86 firetime.min.should == 0
87 firetime.sec.should == 0
88 firetime.day.should == 24
89 firetime.month.should == 2
90 end
a024e4a0 »
2008-06-19 reorganize test files
91
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
92 specify "should return firetime based on day restriction" do
93 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
94 # 21st of every month run every 5 hour
95 a = BackgrounDRb::CronTrigger.new("0 0 */5 21 * * *")
96 firetime = a.fire_after_time(t_time)
97 firetime.hour.should == 0
98 firetime.min.should == 0
99 firetime.sec.should == 0
100 firetime.day.should == 21
101 firetime.month.should == 2
a024e4a0 »
2008-06-19 reorganize test files
102
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
103 t_time = Time.parse("Wed Feb 22 20:53:43 +0530 2008")
104 # 21st of every month run every 5 hour
105 a = BackgrounDRb::CronTrigger.new("0 0 */5 21 * * *")
106 firetime = a.fire_after_time(t_time)
107 firetime.hour.should == 0
108 firetime.min.should == 0
109 firetime.sec.should == 0
110 firetime.day.should == 21
111 firetime.month.should == 3
112 end
a024e4a0 »
2008-06-19 reorganize test files
113
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
114 specify "for feb month should take into account day count" do
115 t_time = Time.parse("Thu Feb 28 20:53:43 +0530 2008")
116 # 21st of every month run every 5 hour
117 a = BackgrounDRb::CronTrigger.new("0 0 */5 30 * * *")
118 firetime = a.fire_after_time(t_time)
119 firetime.hour.should == 0
120 firetime.min.should == 0
121 firetime.sec.should == 0
122 firetime.day.should == 30
123 firetime.month.should == 3
124 end
a024e4a0 »
2008-06-19 reorganize test files
125
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
126 specify "should take care if number of days is not available in month" do
127 t_time = Time.parse("Tue Nov 12 20:53:43 +0530 2007")
128 # 21st of every month run every 5 hour
129 a = BackgrounDRb::CronTrigger.new("0 0 */5 31 * * *")
130 firetime = a.fire_after_time(t_time)
131 firetime.hour.should == 0
132 firetime.min.should == 0
133 firetime.sec.should == 0
134 firetime.day.should == 31
135 firetime.month.should == 12
136 end
a024e4a0 »
2008-06-19 reorganize test files
137
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
138 specify "should take care of periodic variations in day restrictions" do
139 t_time = Time.parse("Tue Aug 12 20:53:43 +0530 2007")
140 a = BackgrounDRb::CronTrigger.new("0 0 */5 */2 1-5 * *")
141 firetime = a.fire_after_time(t_time)
142 firetime.hour.should == 0
143 firetime.min.should == 0
144 firetime.sec.should == 0
145 firetime.day.should == 1
146 firetime.month.should == 1
147 firetime.year.should == 2008
a024e4a0 »
2008-06-19 reorganize test files
148
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
149 t_time = Time.parse("Tue Aug 12 20:53:43 +0530 2007")
150 a = BackgrounDRb::CronTrigger.new("0 0 */5 */3 1-5 * *")
151 firetime = a.fire_after_time(t_time)
152 firetime.hour.should == 0
153 firetime.min.should == 0
154 firetime.sec.should == 0
155 firetime.day.should == 1
156 firetime.month.should == 1
157 firetime.year.should == 2008
158
159 t_time = Time.parse("Tue Aug 12 20:53:43 +0530 2007")
160 a = BackgrounDRb::CronTrigger.new("0 0 */1 */7 1-5 * *")
161 firetime = a.fire_after_time(t_time)
162 firetime.hour.should == 0
163 firetime.min.should == 0
164 firetime.sec.should == 0
165 firetime.day.should == 1
166 firetime.month.should == 1
167 firetime.year.should == 2008
168 end
a024e4a0 »
2008-06-19 reorganize test files
169
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
170 specify "should return firetime based on hour restriction" do
171 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
172 a = BackgrounDRb::CronTrigger.new("0 0 */5 * * * *")
173 firetime = a.fire_after_time(t_time)
174 firetime.hour.should == 0
175 firetime.min.should == 0
176 firetime.sec.should == 0
177 firetime.day.should == 14
178 firetime.month.should == 2
179 end
a024e4a0 »
2008-06-19 reorganize test files
180
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
181 specify "should take care of both fuck restrictions" do
a024e4a0 »
2008-06-19 reorganize test files
182
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
183 # in case of conflict between day and wday options, we should chose one closer to current time
184 t_time = Time.parse("Tue Aug 12 20:53:43 +0530 2007")
185 a = BackgrounDRb::CronTrigger.new("0 0 */5 */3 1-5 3-5 *")
186 firetime = a.fire_after_time(t_time)
187 firetime.hour.should == 0
188 firetime.min.should == 0
189 firetime.sec.should == 0
190 firetime.day.should == 1
191 firetime.wday.should == 2
192 firetime.month.should == 1
193 firetime.year.should == 2008
194 end
a024e4a0 »
2008-06-19 reorganize test files
195
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
196 specify "for user reported trigger" do
197 # on friday
198 t_time = Time.parse("Fri Jan 18 4:53:43 +0530 2008")
199 a = BackgrounDRb::CronTrigger.new("0 0/5 09-17 * * 1,3,5 *")
200 firetime = a.fire_after_time(t_time)
201 firetime.hour.should == 9
202 firetime.min.should == 0
203 firetime.sec.should == 0
204 firetime.wday.should == 5
205 firetime.month.should == 1
206 firetime.year.should == 2008
a024e4a0 »
2008-06-19 reorganize test files
207
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
208 t_time = Time.parse("Fri Jan 18 9:53:43 +0530 2008")
209 a = BackgrounDRb::CronTrigger.new("0 0/5 09-17 * * 1,3,5 *")
210 firetime = a.fire_after_time(t_time)
211 firetime.hour.should == 9
212 firetime.min.should == 55
213 firetime.sec.should == 0
214 firetime.wday.should == 5
215 firetime.month.should == 1
216 firetime.day.should == 18
217 firetime.year.should == 2008
218
219 t_time = Time.parse("Sat Jan 19 4:53:43 +0530 2008")
220 a = BackgrounDRb::CronTrigger.new("0 0/5 09-17 * * 1,3,5 *")
221 firetime = a.fire_after_time(t_time)
222 firetime.hour.should == 9
223 firetime.min.should == 0
224 firetime.sec.should == 0
225 firetime.wday.should == 1
226 firetime.month.should == 1
227 firetime.day.should == 21
228 firetime.year.should == 2008
229
230 t_time = Time.parse("Mon Jan 21 4:53:43 +0530 2008")
231 a = BackgrounDRb::CronTrigger.new("0 0/5 09-17 * * 1,3,5 *")
232 firetime = a.fire_after_time(t_time)
233 firetime.hour.should == 9
234 firetime.min.should == 0
235 firetime.sec.should == 0
236 firetime.wday.should == 1
237 firetime.month.should == 1
238 firetime.day.should == 21
239 firetime.year.should == 2008
a024e4a0 »
2008-06-19 reorganize test files
240
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
241 t_time = Time.parse("Tue Jan 1 4:53:43 +0530 2008")
242 a = BackgrounDRb::CronTrigger.new("0 0/5 09-17 * * 1,3,5 *")
243 firetime = a.fire_after_time(t_time)
244 firetime.hour.should == 9
245 firetime.min.should == 0
246 firetime.sec.should == 0
247 firetime.wday.should == 3
248 firetime.month.should == 1
249 firetime.day.should == 2
250 firetime.year.should == 2008
251 end
a024e4a0 »
2008-06-19 reorganize test files
252
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
253 specify "should return firetime based on month restriction" do
254 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
255 a = BackgrounDRb::CronTrigger.new("0 0 */5 * * * *")
256 firetime = a.fire_after_time(t_time)
257 firetime.hour.should == 0
258 firetime.min.should == 0
259 firetime.sec.should == 0
260 firetime.day.should == 14
261 firetime.month.should == 2
262 end
a71c0cac »
2008-07-02 testcase for weekly trigger
263
264 specify "should run for weekdays " do
265 t_time = Time.parse("Wed Feb 13 20:53:43 +0530 2008")
266 a = BackgrounDRb::CronTrigger.new("0 0 2 * * 1-5 *")
267 firetime = a.fire_after_time(t_time)
268 firetime.hour.should == 2
269 firetime.min.should == 0
270 firetime.sec.should == 0
271 firetime.wday.should == 4
272
273 t_time = Time.parse("Fri June 6 20:53:43 +0530 2008")
274 a = BackgrounDRb::CronTrigger.new("0 0 2 * * 1-5 *")
275 firetime = a.fire_after_time(t_time)
276 firetime.hour.should == 2
277 firetime.min.should == 0
278 firetime.sec.should == 0
279 firetime.wday.should == 1
280 end
7bf3c631 »
2008-02-13 check in new files that fix existing stuff with cron trigger
281 end
Something went wrong with that request. Please try again.