forked from MontFerret/ferret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate_test.go
49 lines (44 loc) · 1009 Bytes
/
date_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package datetime_test
import (
"testing"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/stdlib/datetime"
)
func TestDate(t *testing.T) {
tcs := []*testCase{
&testCase{
Name: "When more than 1 arguments",
Expected: values.None,
Args: []core.Value{
values.NewString("string"),
values.NewInt(0),
},
ShouldErr: true,
},
&testCase{
Name: "When 0 arguments",
Expected: values.None,
Args: []core.Value{},
ShouldErr: true,
},
&testCase{
Name: "When incorrect timeStrings",
Expected: values.None,
Args: []core.Value{
values.NewString("bla-bla"),
},
ShouldErr: true,
},
&testCase{
Name: "When correct timeString in RFC3339 format",
Expected: mustDefaultLayoutDt("1999-02-07T15:04:05Z"),
Args: []core.Value{
values.NewString("1999-02-07T15:04:05Z"),
},
},
}
for _, tc := range tcs {
tc.Do(t, datetime.Date)
}
}