@@ -2,7 +2,6 @@ package gronx
2
2
3
3
import (
4
4
"fmt"
5
- "log"
6
5
"strings"
7
6
"testing"
8
7
"time"
@@ -15,13 +14,16 @@ type Case struct {
15
14
Next string `json:"next"`
16
15
}
17
16
18
- func (test Case ) run (gron Gronx ) (bool , error ) {
17
+ func (test Case ) run (t * testing. T , gron * Gronx ) (bool , error ) {
19
18
if test .Ref == "" {
20
19
return gron .IsDue (test .Expr )
21
20
}
22
21
23
22
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
+ }
25
27
26
28
return gron .IsDue (test .Expr , ref )
27
29
}
@@ -144,7 +146,7 @@ func TestIsDue(t *testing.T) {
144
146
145
147
for i , test := range testcases () {
146
148
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 )
148
150
149
151
if actual != test .Expect {
150
152
t .Errorf ("expected %v, got %v" , test .Expect , actual )
@@ -154,7 +156,7 @@ func TestIsDue(t *testing.T) {
154
156
155
157
for i , test := range errcases () {
156
158
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 )
158
160
159
161
if actual != test .Expect {
160
162
t .Errorf ("expected %v, got %v" , test .Expect , actual )
@@ -289,13 +291,7 @@ func errcases() []Case {
289
291
{"* * * * * ZL" , "" , false , "" },
290
292
{"* * * * * Z#" , "" , false , "" },
291
293
{"* * * * * 1#Z" , "" , false , "" },
292
- {"* * W * 3 " , "" , false , "" },
294
+ {"* * W * L " , "" , false , "" },
293
295
{"* * 15 * 1#Z" , "" , false , "" },
294
296
}
295
297
}
296
-
297
- func abort (err error ) {
298
- if err != nil {
299
- log .Fatalf ("%+v" , err )
300
- }
301
- }
0 commit comments