MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / TestDateTimeUnmarshalJSON

Function TestDateTimeUnmarshalJSON

tools/types/datetime_test.go:334–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

332}
333
334func TestDateTimeUnmarshalJSON(t *testing.T) {
335 scenarios := []struct {
336 date string
337 expected string
338 }{
339 {"", ""},
340 {"invalid_json", ""},
341 {"'123'", ""},
342 {"2022-01-01 11:23:45.678", ""},
343 {`"2022-01-01 11:23:45.678"`, "2022-01-01 11:23:45.678Z"},
344 }
345
346 for i, s := range scenarios {
347 t.Run(fmt.Sprintf("%d_%s", i, s.date), func(t *testing.T) {
348 dt := types.DateTime{}
349 dt.UnmarshalJSON([]byte(s.date))
350
351 if dt.String() != s.expected {
352 t.Fatalf("Expected %q, got %q", s.expected, dt.String())
353 }
354 })
355 }
356}
357
358func TestDateTimeValue(t *testing.T) {
359 scenarios := []struct {

Callers

nothing calls this directly

Calls 3

UnmarshalJSONMethod · 0.95
StringMethod · 0.95
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…