chore: remove outdated tests
ci/woodpecker/pr/build Pipeline is pending
Details
ci/woodpecker/pr/docker Pipeline is pending
Details
ci/woodpecker/pr/docs Pipeline is pending
Details
ci/woodpecker/pr/lint Pipeline is pending
Details
ci/woodpecker/pr/man Pipeline is pending
Details
ci/woodpecker/pr/test Pipeline is pending
Details
ci/woodpecker/pr/build Pipeline is pending
Details
ci/woodpecker/pr/docker Pipeline is pending
Details
ci/woodpecker/pr/docs Pipeline is pending
Details
ci/woodpecker/pr/lint Pipeline is pending
Details
ci/woodpecker/pr/man Pipeline is pending
Details
ci/woodpecker/pr/test Pipeline is pending
Details
parent
a135068b31
commit
b47d78c41c
|
@ -1,89 +0,0 @@
|
||||||
module cron
|
|
||||||
|
|
||||||
// parse_range_error returns the returned error message. If the result is '',
|
|
||||||
// that means the function didn't error.
|
|
||||||
fn parse_range_error(s string, min int, max int) string {
|
|
||||||
parse_range(s, min, max) or { return err.msg }
|
|
||||||
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// =====parse_range=====
|
|
||||||
fn test_range_star_range() ! {
|
|
||||||
bf := parse_range('*', 0, 5)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 0) == [0, 1, 2, 3, 4, 5]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_number() ! {
|
|
||||||
bf := parse_range('4', 0, 5)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 0) == [4]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_number_too_large() ! {
|
|
||||||
assert parse_range_error('10', 0, 6) == 'Out of range.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_number_too_small() ! {
|
|
||||||
assert parse_range_error('0', 2, 6) == 'Out of range.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_number_invalid() ! {
|
|
||||||
assert parse_range_error('x', 0, 6) == 'Invalid number.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_star_1() ! {
|
|
||||||
bf := parse_range('*/4', 0, 20)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 0) == [0, 4, 8, 12, 16, 20]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_star_2() ! {
|
|
||||||
bf := parse_range('*/3', 1, 8)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 1) == [1, 4, 7]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_star_too_large() ! {
|
|
||||||
assert parse_range_error('*/21', 0, 20) == 'Step size too large.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_zero() ! {
|
|
||||||
assert parse_range_error('*/0', 0, 20) == 'Step size zero not allowed.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_number() ! {
|
|
||||||
bf := parse_range('5/4', 2, 22)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 2) == [5, 9, 13, 17, 21]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_number_too_large() ! {
|
|
||||||
assert parse_range_error('10/4', 0, 5) == 'Out of range.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_step_number_too_small() ! {
|
|
||||||
assert parse_range_error('2/4', 5, 10) == 'Out of range.'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_dash() ! {
|
|
||||||
bf := parse_range('4-8', 0, 9)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 0) == [4, 5, 6, 7, 8]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_range_dash_step() ! {
|
|
||||||
bf := parse_range('4-8/2', 0, 9)!
|
|
||||||
|
|
||||||
assert bf_to_ints(bf, 0) == [4, 6, 8]
|
|
||||||
}
|
|
||||||
|
|
||||||
// =====parse_part=====
|
|
||||||
fn test_part_single() ! {
|
|
||||||
assert parse_part('*', 0, 5)! == [0, 1, 2, 3, 4, 5]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_part_multiple() ! {
|
|
||||||
assert parse_part('*/2,2/3', 1, 8)! == [1, 2, 3, 5, 7, 8]
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@ fn test_next_simple() ! {
|
||||||
util_test_time(exp, '2002-01-01 03:00:00', '2002-01-02 03:00:00')!
|
util_test_time(exp, '2002-01-01 03:00:00', '2002-01-02 03:00:00')!
|
||||||
util_test_time(exp, '2002-01-01 04:00:00', '2002-01-02 03:00:00')!
|
util_test_time(exp, '2002-01-01 04:00:00', '2002-01-02 03:00:00')!
|
||||||
|
|
||||||
util_test_time('0 3/4', '2002-01-01 04:00:00', '2002-01-01 07:00:00')!
|
util_test_time('0 3-7/4,7-19', '2002-01-01 04:00:00', '2002-01-01 07:00:00')!
|
||||||
|
|
||||||
//// Overlap to next month
|
//// Overlap to next month
|
||||||
util_test_time('0 3', '2002-11-31 04:00:00', '2002-12-01 03:00:00')!
|
util_test_time('0 3', '2002-11-31 04:00:00', '2002-12-01 03:00:00')!
|
||||||
|
@ -37,8 +37,10 @@ fn test_next_simple() ! {
|
||||||
|
|
||||||
fn test_leading_star() {
|
fn test_leading_star() {
|
||||||
mut x := false
|
mut x := false
|
||||||
|
|
||||||
parse_expression('*5 8') or { x = true }
|
parse_expression('*5 8') or { x = true }
|
||||||
|
assert x
|
||||||
|
|
||||||
|
x = false
|
||||||
|
parse_expression('x 8') or { x = true }
|
||||||
assert x
|
assert x
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue