Skip to content

Commit b2e2c14

Browse files
committed
test: update tests
1 parent 0bde39a commit b2e2c14

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

gronx_test.go

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gronx
22

33
import (
44
"fmt"
5-
"log"
65
"strings"
76
"testing"
87
"time"
@@ -15,13 +14,16 @@ type Case struct {
1514
Next string `json:"next"`
1615
}
1716

18-
func (test Case) run(gron Gronx) (bool, error) {
17+
func (test Case) run(t *testing.T, gron *Gronx) (bool, error) {
1918
if test.Ref == "" {
2019
return gron.IsDue(test.Expr)
2120
}
2221

2322
ref, err := time.Parse(FullDateFormat, test.Ref)
24-
abort(err)
23+
if err != nil {
24+
t.Errorf("can't parse date: %s", test.Ref)
25+
t.Fail()
26+
}
2527

2628
return gron.IsDue(test.Expr, ref)
2729
}
@@ -144,7 +146,7 @@ func TestIsDue(t *testing.T) {
144146

145147
for i, test := range testcases() {
146148
t.Run(fmt.Sprintf("is due #%d=%s", i, test.Expr), func(t *testing.T) {
147-
actual, _ := test.run(gron)
149+
actual, _ := test.run(t, gron)
148150

149151
if actual != test.Expect {
150152
t.Errorf("expected %v, got %v", test.Expect, actual)
@@ -154,7 +156,7 @@ func TestIsDue(t *testing.T) {
154156

155157
for i, test := range errcases() {
156158
t.Run(fmt.Sprintf("is due err #%d=%s", i, test.Expr), func(t *testing.T) {
157-
actual, err := test.run(gron)
159+
actual, err := test.run(t, gron)
158160

159161
if actual != test.Expect {
160162
t.Errorf("expected %v, got %v", test.Expect, actual)
@@ -289,13 +291,7 @@ func errcases() []Case {
289291
{"* * * * * ZL", "", false, ""},
290292
{"* * * * * Z#", "", false, ""},
291293
{"* * * * * 1#Z", "", false, ""},
292-
{"* * W * 3", "", false, ""},
294+
{"* * W * L", "", false, ""},
293295
{"* * 15 * 1#Z", "", false, ""},
294296
}
295297
}
296-
297-
func abort(err error) {
298-
if err != nil {
299-
log.Fatalf("%+v", err)
300-
}
301-
}

0 commit comments

Comments
 (0)