Fix untyped integer overflows on 32-bit archs (#857)

go-sqlmock's Rows.AddRow() takes values which have a type alias of
"any", and appear to default to untyped ints if not explicitly cast.
When large values are passed which would overflow int32, tests fail.

Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
This commit is contained in:
Daniel Swarbrick 2023-07-05 15:10:47 +02:00 committed by GitHub
parent a6012e0b54
commit 2477aba363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -51,7 +51,7 @@ func TestPGStatBGWriterCollector(t *testing.T) {
} }
rows := sqlmock.NewRows(columns). rows := sqlmock.NewRows(columns).
AddRow(354, 4945, 289097744, 1242257, 3275602074, 89320867, 450139, 2034563757, 0, 2725688749, srT) AddRow(354, 4945, 289097744, 1242257, int64(3275602074), 89320867, 450139, 2034563757, 0, int64(2725688749), srT)
mock.ExpectQuery(sanitizeQuery(statBGWriterQuery)).WillReturnRows(rows) mock.ExpectQuery(sanitizeQuery(statBGWriterQuery)).WillReturnRows(rows)
ch := make(chan prometheus.Metric) ch := make(chan prometheus.Metric)

View File

@ -67,12 +67,12 @@ func TestPGStatDatabaseCollector(t *testing.T) {
4945, 4945,
289097744, 289097744,
1242257, 1242257,
3275602074, int64(3275602074),
89320867, 89320867,
450139, 450139,
2034563757, 2034563757,
0, 0,
2725688749, int64(2725688749),
23, 23,
52, 52,
74, 74,
@ -263,12 +263,12 @@ func TestPGStatDatabaseCollectorRowLeakTest(t *testing.T) {
4945, 4945,
289097744, 289097744,
1242257, 1242257,
3275602074, int64(3275602074),
89320867, 89320867,
450139, 450139,
2034563757, 2034563757,
0, 0,
2725688749, int64(2725688749),
23, 23,
52, 52,
74, 74,