Skip to content

Commit 53acbaf

Browse files
jackcclaude
andcommitted
test(pgtype): move interval malformed-text test into interval_test.go
Consolidate TestIntervalScanMalformedTimeReturnsError into the existing interval_test.go and remove the separate interval_malformed_test.go file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 38355b2 commit 53acbaf

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

pgtype/interval_malformed_test.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

pgtype/interval_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,15 @@ func TestIntervalTextEncode(t *testing.T) {
156156
assert.Equalf(t, tt.result, string(buf), "%d", i)
157157
}
158158
}
159+
160+
// A malformed interval whose time component has an empty hours segment
161+
// (for example ":05:06") must return an error instead of panicking with an
162+
// index out of range on timeParts[0][0].
163+
func TestIntervalScanMalformedTimeReturnsError(t *testing.T) {
164+
for _, src := range []string{":05:06", "1 day :30:00"} {
165+
var v pgtype.Interval
166+
if err := v.Scan(src); err == nil {
167+
t.Errorf("Scan(%q): expected error, got nil", src)
168+
}
169+
}
170+
}

0 commit comments

Comments
 (0)