github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/datetime/dayofweek_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 TestDateDayOfWeek(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 Sunday (0th day)",
    36  			Expected: values.NewInt(0),
    37  			Args:     []core.Value{mustDefaultLayoutDt("1999-02-07T15:04:05Z")},
    38  		},
    39  		&testCase{
    40  			Name:     "When Monday (1th day)",
    41  			Expected: values.NewInt(1),
    42  			Args:     []core.Value{mustDefaultLayoutDt("1999-02-08T15:04:05Z")},
    43  		},
    44  	}
    45  
    46  	for _, tc := range tcs {
    47  		tc.Do(t, datetime.DateDayOfWeek)
    48  	}
    49  }