MCPcopy
hub / github.com/go-sql-driver/mysql / TestInvalidDateTime

Function TestInvalidDateTime

utils_test.go:461–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

459}
460
461func TestInvalidDateTime(t *testing.T) {
462 cases := []struct {
463 name string
464 str string
465 want time.Time
466 }{
467 {
468 name: "parse datetime without day",
469 str: "0000-00-00 21:30:45",
470 want: time.Date(0, 0, 0, 21, 30, 45, 0, time.UTC),
471 },
472 }
473
474 for _, cc := range cases {
475 t.Run(cc.name, func(t *testing.T) {
476 got, err := parseDateTime([]byte(cc.str), time.UTC)
477 if err != nil {
478 t.Fatal(err)
479 }
480
481 if !cc.want.Equal(got) {
482 t.Fatalf("want: %v, but got %v", cc.want, got)
483 }
484 })
485 }
486}
487
488func TestParseDateTimeFail(t *testing.T) {
489 cases := []struct {

Callers

nothing calls this directly

Calls 1

parseDateTimeFunction · 0.85

Tested by

no test coverage detected