add and test style from file

This commit is contained in:
bel
2020-03-15 16:55:46 +00:00
parent c1fe373427
commit 9d51626e4b
4 changed files with 52 additions and 8 deletions

View File

@@ -153,3 +153,42 @@ func TestSchedulerFromFile(t *testing.T) {
})
}
}
func TestSplitScheduleCommandTitle(t *testing.T) {
cases := map[string]struct {
in string
schedule string
command string
title string
}{
"invalid schedule": {
in: "* * * cmd #title",
},
"no title": {
in: "* * * * * cmd ",
schedule: "* * * * *",
command: "cmd",
},
"schedule, command, title": {
in: "* * * * * cmd #title",
schedule: "* * * * *",
command: "cmd #title",
title: "title",
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
s, a, l := splitScheduleCommandTitle([]byte(c.in))
if s != c.schedule {
t.Error(s)
}
if a != c.command {
t.Error(a)
}
if l != c.title {
t.Error(l)
}
})
}
}