MCPcopy Create free account
hub / github.com/apache/devlake / TestParseDate

Function TestParseDate

backend/plugins/q_dev/tasks/s3_data_extractor_test.go:396–420  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

394}
395
396func TestParseDate(t *testing.T) {
397 testCases := []struct {
398 dateStr string
399 expectedDate time.Time
400 expectError bool
401 }{
402 {"2025-07-10", time.Date(2025, 7, 10, 0, 0, 0, 0, time.UTC), false},
403 {"2025/07/10", time.Date(2025, 7, 10, 0, 0, 0, 0, time.UTC), false},
404 {"07/10/2025", time.Date(2025, 7, 10, 0, 0, 0, 0, time.UTC), false},
405 {"07-10-2025", time.Date(2025, 7, 10, 0, 0, 0, 0, time.UTC), false},
406 {"2025-07-10T15:04:05Z", time.Date(2025, 7, 10, 15, 4, 5, 0, time.UTC), false},
407 {"invalid-date", time.Time{}, true},
408 }
409
410 for _, tc := range testCases {
411 date, err := parseDate(tc.dateStr)
412
413 if tc.expectError {
414 assert.Error(t, err)
415 } else {
416 assert.NoError(t, err)
417 assert.Equal(t, tc.expectedDate, date)
418 }
419 }
420}
421
422func TestDetectUserReportFormat(t *testing.T) {
423 // New format: contains Client_Type

Callers

nothing calls this directly

Calls 2

parseDateFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected