(t *testing.T)
| 936 | } |
| 937 | |
| 938 | func TestRecordGetDateTime(t *testing.T) { |
| 939 | t.Parallel() |
| 940 | |
| 941 | nowTime := time.Now() |
| 942 | testTime, _ := time.Parse(types.DefaultDateLayout, "2022-01-01 08:00:40.000Z") |
| 943 | |
| 944 | scenarios := []struct { |
| 945 | value any |
| 946 | expected time.Time |
| 947 | }{ |
| 948 | {nil, time.Time{}}, |
| 949 | {"", time.Time{}}, |
| 950 | {false, time.Time{}}, |
| 951 | {true, time.Time{}}, |
| 952 | {"test", time.Time{}}, |
| 953 | {[]string{"true"}, time.Time{}}, |
| 954 | {map[string]int{"test": 1}, time.Time{}}, |
| 955 | {1641024040, testTime}, |
| 956 | {"2022-01-01 08:00:40.000", testTime}, |
| 957 | {nowTime, nowTime}, |
| 958 | } |
| 959 | |
| 960 | collection := core.NewBaseCollection("test") |
| 961 | record := core.NewRecord(collection) |
| 962 | |
| 963 | for i, s := range scenarios { |
| 964 | t.Run(fmt.Sprintf("%d_%#v", i, s.value), func(t *testing.T) { |
| 965 | record.Set("test", s.value) |
| 966 | |
| 967 | result := record.GetDateTime("test") |
| 968 | if !result.Time().Equal(s.expected) { |
| 969 | t.Fatalf("Expected %v, got %v", s.expected, result) |
| 970 | } |
| 971 | }) |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | func TestRecordGetStringSlice(t *testing.T) { |
| 976 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…