MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestDecodeTimestampAncient

Function TestDecodeTimestampAncient

server/types_test.go:1360–1389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1358}
1359
1360func TestDecodeTimestampAncient(t *testing.T) {
1361 // Bug 8: timestamps before ~1700 were corrupted due to time.Duration overflow.
1362 // This test verifies the fix works for ancient dates.
1363 tests := []struct {
1364 name string
1365 input time.Time
1366 }{
1367 {"2024-01-15", time.Date(2024, 1, 15, 10, 30, 0, 0, time.UTC)},
1368 {"1970-01-01", time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)},
1369 {"1000-06-15", time.Date(1000, 6, 15, 12, 0, 0, 0, time.UTC)},
1370 {"0100-01-01", time.Date(100, 1, 1, 0, 0, 0, 0, time.UTC)},
1371 {"0001-01-01", time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)},
1372 }
1373
1374 for _, tt := range tests {
1375 t.Run(tt.name, func(t *testing.T) {
1376 encoded := encodeTimestamp(tt.input)
1377 if encoded == nil {
1378 t.Fatalf("encodeTimestamp(%v) returned nil", tt.input)
1379 }
1380 decoded, err := decodeTimestamp(encoded)
1381 if err != nil {
1382 t.Fatalf("decodeTimestamp error: %v", err)
1383 }
1384 if !decoded.Equal(tt.input) {
1385 t.Errorf("round-trip: got %v, want %v", decoded, tt.input)
1386 }
1387 })
1388 }
1389}
1390
1391// TestEncodeJSON verifies that encodeJSON re-serializes Go native values back
1392// to valid JSON text. The Go DuckDB driver's getJSON() deserializes JSON via

Callers

nothing calls this directly

Calls 4

encodeTimestampFunction · 0.85
decodeTimestampFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected