Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecd7612

Browse files
test: add some minor tests
1 parent748e893 commitecd7612

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎coderd/schedule/cron/cron_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func TestIsWithinRange(t *testing.T) {
170170
specstring
171171
at time.Time
172172
expectedWithinRangebool
173+
expectedErrorstring
173174
}{
174175
// "* 9-18 * * 1-5" should be interpreted as a continuous time range from 08:59:00 to 18:58:59, Monday through Friday
175176
{
@@ -238,13 +239,30 @@ func TestIsWithinRange(t *testing.T) {
238239
at:mustParseTime(t,time.RFC1123,"Sun, 08 Jun 2025 14:00:00 UTC"),
239240
expectedWithinRange:false,
240241
},
242+
{
243+
name:"Check that Sunday is supported with value 0",
244+
spec:"* 9-18 * * 0",
245+
at:mustParseTime(t,time.RFC1123,"Sun, 08 Jun 2025 14:00:00 UTC"),
246+
expectedWithinRange:true,
247+
},
248+
{
249+
name:"Check that value 7 is rejected as out of range",
250+
spec:"* 9-18 * * 7",
251+
at:mustParseTime(t,time.RFC1123,"Sun, 08 Jun 2025 14:00:00 UTC"),
252+
expectedError:"end of range (7) above maximum (6): 7",
253+
},
241254
}
242255

243256
for_,testCase:=rangetestCases {
244257
testCase:=testCase
245258
t.Run(testCase.name,func(t*testing.T) {
246259
t.Parallel()
247260
sched,err:=cron.Weekly(testCase.spec)
261+
iftestCase.expectedError!="" {
262+
require.Error(t,err)
263+
require.Contains(t,err.Error(),testCase.expectedError)
264+
return
265+
}
248266
require.NoError(t,err)
249267
withinRange:=sched.IsWithinRange(testCase.at)
250268
require.Equal(t,testCase.expectedWithinRange,withinRange)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp