mirror of
https://github.com/MontFerret/ferret.git
synced 2025-11-25 22:01:39 +02:00
Feature/#8 datetime (#153)
This commit is contained in:
49
pkg/stdlib/datetime/date_test.go
Normal file
49
pkg/stdlib/datetime/date_test.go
Normal file
@@ -0,0 +1,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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user