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

Function TestAppendDateTime

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

Source from the content-addressed store, hash-verified

271}
272
273func TestAppendDateTime(t *testing.T) {
274 tests := []struct {
275 t time.Time
276 str string
277 timeTruncate time.Duration
278 expectedErr bool
279 }{
280 {
281 t: time.Date(1234, 5, 6, 0, 0, 0, 0, time.UTC),
282 str: "1234-05-06",
283 },
284 {
285 t: time.Date(4567, 12, 31, 12, 0, 0, 0, time.UTC),
286 str: "4567-12-31 12:00:00",
287 },
288 {
289 t: time.Date(2020, 5, 30, 12, 34, 0, 0, time.UTC),
290 str: "2020-05-30 12:34:00",
291 },
292 {
293 t: time.Date(2020, 5, 30, 12, 34, 56, 0, time.UTC),
294 str: "2020-05-30 12:34:56",
295 },
296 {
297 t: time.Date(2020, 5, 30, 22, 33, 44, 123000000, time.UTC),
298 str: "2020-05-30 22:33:44.123",
299 },
300 {
301 t: time.Date(2020, 5, 30, 22, 33, 44, 123456000, time.UTC),
302 str: "2020-05-30 22:33:44.123456",
303 },
304 {
305 t: time.Date(2020, 5, 30, 22, 33, 44, 123456789, time.UTC),
306 str: "2020-05-30 22:33:44.123456789",
307 },
308 {
309 t: time.Date(9999, 12, 31, 23, 59, 59, 999999999, time.UTC),
310 str: "9999-12-31 23:59:59.999999999",
311 },
312 {
313 t: time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC),
314 str: "0001-01-01",
315 },
316 // Truncated time
317 {
318 t: time.Date(1234, 5, 6, 0, 0, 0, 0, time.UTC),
319 str: "1234-05-06",
320 timeTruncate: time.Second,
321 },
322 {
323 t: time.Date(4567, 12, 31, 12, 0, 0, 0, time.UTC),
324 str: "4567-12-31 12:00:00",
325 timeTruncate: time.Minute,
326 },
327 {
328 t: time.Date(2020, 5, 30, 12, 34, 0, 0, time.UTC),
329 str: "2020-05-30 12:34:00",
330 timeTruncate: 0,

Callers

nothing calls this directly

Calls 1

appendDateTimeFunction · 0.85

Tested by

no test coverage detected