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

Function TestDateTimeValue

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

Source from the content-addressed store, hash-verified

356}
357
358func TestDateTimeValue(t *testing.T) {
359 scenarios := []struct {
360 value any
361 expected string
362 }{
363 {"", ""},
364 {"invalid", ""},
365 {1641024040, "2022-01-01 08:00:40.000Z"},
366 {"2022-01-01 11:23:45.678", "2022-01-01 11:23:45.678Z"},
367 {types.NowDateTime(), types.NowDateTime().String()},
368 }
369
370 for i, s := range scenarios {
371 t.Run(fmt.Sprintf("%d_%s", i, s.value), func(t *testing.T) {
372 dt, _ := types.ParseDateTime(s.value)
373
374 result, err := dt.Value()
375 if err != nil {
376 t.Fatal(err)
377 }
378
379 if result != s.expected {
380 t.Fatalf("Expected %q, got %q", s.expected, result)
381 }
382 })
383 }
384}
385
386func TestDateTimeScan(t *testing.T) {
387 now := time.Now().UTC().Format("2006-01-02 15:04:05") // without ms part for test consistency

Callers

nothing calls this directly

Calls 5

NowDateTimeFunction · 0.92
ParseDateTimeFunction · 0.92
StringMethod · 0.45
RunMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…