1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-21 01:21:34 +02:00
ferret/pkg/stdlib/datetime/hour_test.go

50 lines
1.1 KiB
Go
Raw Normal View History

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 TestDateHour(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 argument isn't DateTime",
Expected: values.None,
Args: []core.Value{values.NewInt(0)},
ShouldErr: true,
},
&testCase{
Name: "When 7th hour",
Expected: values.NewInt(7),
Args: []core.Value{mustDefaultLayoutDt("1999-02-07T07:04:05Z")},
},
&testCase{
Name: "When 15th day",
Expected: values.NewInt(15),
Args: []core.Value{mustDefaultLayoutDt("1629-02-28T15:04:05Z")},
},
}
for _, tc := range tcs {
tc.Do(t, datetime.DateHour)
}
}