Skip to content

Commit

Permalink
Merge pull request #34 from krallin/fix-bad-shorthand-parse
Browse files Browse the repository at this point in the history
Fix bad shorthand parse
  • Loading branch information
krallin authored Aug 1, 2018
2 parents 2cf5742 + 4d5c9b9 commit 0ce2c75
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
43 changes: 36 additions & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

[[constraint]]
name = "github.com/gorhill/cronexpr"
version = "~1.0.0"
branch = "strict"
source = "github.com/krallin/cronexpr"

[[constraint]]
name = "github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion crontab/crontab.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func parseJobLine(line string) (*CrontabLine, error) {
// TODO: Should receive a logger?
logrus.Debugf("try parse(%d): %s[0:%d] = %s", count, line, scheduleEnds, line[0:scheduleEnds])

expr, err := cronexpr.Parse(line[:scheduleEnds])
expr, err := cronexpr.ParseStrict(line[:scheduleEnds])

if err != nil {
continue
Expand Down
18 changes: 18 additions & 0 deletions crontab/crontab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,24 @@ var parseCrontabTestCases = []struct {
},
},

{
"@hourly foo1 foo2 foo3 foo4 foo5 foo6",
&Crontab{
Context: &Context{
Shell: "/bin/sh",
Environ: map[string]string{},
},
Jobs: []*Job{
{
CrontabLine: CrontabLine{
Schedule: "@hourly",
Command: "foo1 foo2 foo3 foo4 foo5 foo6",
},
},
},
},
},

// Failure cases
{"* foo \n", nil},
{"* some * * * more\n", nil},
Expand Down

0 comments on commit 0ce2c75

Please sign in to comment.