Skip to content

Commit 54553cb

Browse files
committed
test: Add failing test for parser reader cleanup
1 parent 9174783 commit 54553cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/pg-protocol/src/inbound-parser.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { parse } from '.'
44
import assert from 'assert'
55
import { PassThrough } from 'stream'
66
import { BackendMessage } from './messages'
7+
import { Parser } from './parser'
78

89
const authOkBuffer = buffers.authenticationOk()
910
const paramStatusBuffer = buffers.parameterStatus('client_encoding', 'UTF8')
@@ -565,4 +566,10 @@ describe('PgPacketStream', function () {
565566
})
566567
})
567568
})
569+
570+
it('cleans up the reader after handling a packet', function () {
571+
const parser = new Parser()
572+
parser.parse(oneFieldBuf, () => {})
573+
assert.strictEqual((parser as any).reader.buffer.byteLength, 0)
574+
})
568575
})

0 commit comments

Comments
 (0)