MCPcopy
hub / github.com/pocketbase/pocketbase / TestDateTimeMarshalJSON

Function TestDateTimeMarshalJSON

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

Source from the content-addressed store, hash-verified

304}
305
306func TestDateTimeMarshalJSON(t *testing.T) {
307 scenarios := []struct {
308 date string
309 expected string
310 }{
311 {"", `""`},
312 {"2022-01-01 11:23:45.678", `"2022-01-01 11:23:45.678Z"`},
313 }
314
315 for i, s := range scenarios {
316 t.Run(fmt.Sprintf("%d_%s", i, s.date), func(t *testing.T) {
317 dt, err := types.ParseDateTime(s.date)
318 if err != nil {
319 t.Fatal(err)
320 }
321
322 result, err := dt.MarshalJSON()
323 if err != nil {
324 t.Fatal(err)
325 }
326
327 if string(result) != s.expected {
328 t.Fatalf("Expected %q, got %q", s.expected, string(result))
329 }
330 })
331 }
332}
333
334func TestDateTimeUnmarshalJSON(t *testing.T) {
335 scenarios := []struct {

Callers

nothing calls this directly

Calls 3

ParseDateTimeFunction · 0.92
RunMethod · 0.45
MarshalJSONMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…