Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 22, 2024
1 parent d982d8e commit 24a5428
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lib/debezium/converters/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,21 @@ func TestMicroTime_Converter(t *testing.T) {
func TestConvertTimeWithTimezone(t *testing.T) {
{
// Invalid
ts, err := TimeWithTimezone{}.Convert("23:02")
assert.Nil(t, ts)
assert.ErrorContains(t, err, `failed to parse "23:02": parsing time`)
{
// Malformed
_, err := TimeWithTimezone{}.Convert("23:02")
assert.ErrorContains(t, err, `failed to parse "23:02": parsing time`)
}
{
// Non UTC
_, err := TimeWithTimezone{}.Convert("23:02:06.745116")
assert.ErrorContains(t, err, `failed to parse "23:02:06.745116"`)
}
{
// Providing timezone offset
_, err := TimeWithTimezone{}.Convert("23:02:06.745116Z-07:00")
assert.ErrorContains(t, err, `failed to parse "23:02:06.745116Z-07:00": parsing time "23:02:06.745116Z-07:00": extra text: "-07:00"`)
}
}
{
// What Debezium + Reader would produce (microsecond precision)
Expand Down Expand Up @@ -188,15 +200,4 @@ func TestConvertTimeWithTimezone(t *testing.T) {
assert.Equal(t, expectedTs, val.(*ext.ExtendedTime))
assert.Equal(t, "23:02:06Z", val.(*ext.ExtendedTime).String(""))
}
{
// Non UTC
ts, err := TimeWithTimezone{}.Convert("23:02:06.745116")
assert.ErrorContains(t, err, `failed to parse "23:02:06.745116"`)
assert.Nil(t, ts)

// Providing timezone offset
ts, err = TimeWithTimezone{}.Convert("23:02:06.745116Z-07:00")
assert.ErrorContains(t, err, `failed to parse "23:02:06.745116Z-07:00": parsing time "23:02:06.745116Z-07:00": extra text: "-07:00"`)
assert.Nil(t, ts)
}
}

0 comments on commit 24a5428

Please sign in to comment.