github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/datetime/second_test.go (about) 1 package datetime_test 2 3 import ( 4 "testing" 5 6 "github.com/MontFerret/ferret/pkg/runtime/core" 7 "github.com/MontFerret/ferret/pkg/runtime/values" 8 "github.com/MontFerret/ferret/pkg/stdlib/datetime" 9 ) 10 11 func TestDateSecond(t *testing.T) { 12 tcs := []*testCase{ 13 &testCase{ 14 Name: "When more than 1 arguments", 15 Expected: values.None, 16 Args: []core.Value{ 17 values.NewString("string"), 18 values.NewInt(0), 19 }, 20 ShouldErr: true, 21 }, 22 &testCase{ 23 Name: "When 0 arguments", 24 Expected: values.None, 25 Args: []core.Value{}, 26 ShouldErr: true, 27 }, 28 &testCase{ 29 Name: "When argument isn't DateTime", 30 Expected: values.None, 31 Args: []core.Value{values.NewInt(0)}, 32 ShouldErr: true, 33 }, 34 &testCase{ 35 Name: "When 5th second", 36 Expected: values.NewInt(5), 37 Args: []core.Value{mustDefaultLayoutDt("1999-02-07T15:04:05Z")}, 38 }, 39 &testCase{ 40 Name: "When 59th second", 41 Expected: values.NewInt(59), 42 Args: []core.Value{mustDefaultLayoutDt("1629-02-28T15:59:59Z")}, 43 }, 44 } 45 46 for _, tc := range tcs { 47 tc.Do(t, datetime.DateSecond) 48 } 49 }