Skip to content

Commit c99c749

Browse files
committed
Fix test
Signed-off-by: Jakub Štiller <[email protected]>
1 parent 4fb7c1a commit c99c749

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

collector/pg_stat_statements_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,15 @@ func TestPGStateStatementsCollector_PG17_WithStatement(t *testing.T) {
337337

338338
inst := &instance{db: db, version: semver.MustParse("17.0.0")}
339339

340-
columns := []string{"user", "datname", "queryid", "query", "calls_total", "seconds_total", "rows_total", "block_read_seconds_total", "block_write_seconds_total"}
340+
columns := []string{"user", "datname", "queryid", "LEFT(pg_stat_statements.query, 300) as query", "calls_total", "seconds_total", "rows_total", "block_read_seconds_total", "block_write_seconds_total"}
341341
rows := sqlmock.NewRows(columns).
342342
AddRow("postgres", "postgres", 1500, "select 1 from foo", 5, 0.4, 100, 0.1, 0.2)
343-
mock.ExpectQuery(sanitizeQuery(fmt.Sprintf(pgStatStatementsQuery_PG17, pgStatStatementQuerySelect))).WillReturnRows(rows)
343+
mock.ExpectQuery(sanitizeQuery(fmt.Sprintf(pgStatStatementsQuery_PG17, fmt.Sprintf(pgStatStatementQuerySelect, 300)))).WillReturnRows(rows)
344344

345345
ch := make(chan prometheus.Metric)
346346
go func() {
347347
defer close(ch)
348-
c := PGStatStatementsCollector{includeQueryStatement: true}
348+
c := PGStatStatementsCollector{includeQueryStatement: true, statementLength: 300}
349349

350350
if err := c.Update(context.Background(), inst, ch); err != nil {
351351
t.Errorf("Error calling PGStatStatementsCollector.Update: %s", err)

0 commit comments

Comments
 (0)