Files
peardata/test/postgres-collector.test.js
T
Raven Scott 1d46b7b3ad
CI / test (push) Failing after 6s
Release rolling / release (push) Has been cancelled
updates
2026-07-18 19:11:32 -04:00

30 lines
723 B
JavaScript

import test from 'brittle'
import {
parsePostgresStats,
isPostgresEnabled,
} from '../server/services/collectors/postgres.js'
test('parsePostgresStats', (t) => {
const s = parsePostgresStats(`
# comment
connections=18
xact_commit: 1000
xact_rollback=2
tuples_returned=50000
`)
t.is(s.connections, 18)
t.is(s.xact_commit, 1000)
t.is(s.xact_rollback, 2)
t.is(s.tuples_returned, 50000)
})
test('isPostgresEnabled', (t) => {
const prev = process.env.PEARDATA_POSTGRES
delete process.env.PEARDATA_POSTGRES
t.absent(isPostgresEnabled())
process.env.PEARDATA_POSTGRES = '1'
t.ok(isPostgresEnabled())
if (prev == null) delete process.env.PEARDATA_POSTGRES
else process.env.PEARDATA_POSTGRES = prev
})