firestormy/scheduler/parser_test.go

38 lines
516 B
Go
Executable File

package scheduler
import "testing"
func TestValidCronFail(t *testing.T) {
cases := []string{
"a 1 1 1 1",
"1 1 1 1",
"@minutely",
}
for _, c := range cases {
if validCron(c) {
t.Error("should fail:", c)
}
}
}
func TestValidCronPass(t *testing.T) {
cases := []string{
"1 1 1 1 1",
"* * 1 1 1",
"@hourly",
"1 1 1 1 1 1",
"@daily",
"@yearly",
"@weekly",
"* */5 1 1 1",
"*/5 * */5 1 1 1",
}
for _, c := range cases {
if !validCron(c) {
t.Error("should pass:", c)
}
}
}