Skip to content

Commit ffb4a46

Browse files
authored
Add chain-of-messages tests for response parser (#126)
The existing single-message parser tests can pass even if the parser doesn't fully consume a message (e.g., missing a null terminator), because there's no subsequent message whose parsing would be corrupted. These chain tests concatenate multiple messages into a single buffer and verify the parser correctly advances through each one. Adds a property-based test with a generator covering all 26 parseable message types (random sequences of 2-8 messages, verifying each parse yields non-None and the buffer is fully consumed), plus 7 example-based tests covering realistic protocol sequences with field-level assertions: SimpleQueryResult, CopyOutSequence, EmptyQuerySequence, PrepareSequence, CloseStatementSequence, SASLFullSequence, and RemainingTypes. Resolves the TODO at the former line 6 of `_test_response_parser.pony`.
1 parent b26d3d7 commit ffb4a46

File tree

2 files changed

+623
-9
lines changed

2 files changed

+623
-9
lines changed

postgres/_test.pony

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ actor \nodoc\ Main is TestList
120120
test(_TestResponseParserAuthenticationSASLFinalMessage)
121121
test(_TestResponseParserUnsupportedAuthenticationMessage)
122122
test(_TestResponseParserMultipleMessagesSASLFirst)
123+
test(Property1UnitTest[Array[Array[U8] val] val](
124+
_TestResponseParserMultipleMessagesChainProperty))
125+
test(_TestResponseParserMultipleMessagesChainSimpleQueryResult)
126+
test(_TestResponseParserMultipleMessagesChainCopyOutSequence)
127+
test(_TestResponseParserMultipleMessagesChainEmptyQuerySequence)
128+
test(_TestResponseParserMultipleMessagesChainPrepareSequence)
129+
test(_TestResponseParserMultipleMessagesChainCloseStatementSequence)
130+
test(_TestResponseParserMultipleMessagesChainSASLFullSequence)
131+
test(_TestResponseParserMultipleMessagesChainRemainingTypes)
123132
test(_TestFrontendMessageSASLInitialResponse)
124133
test(_TestFrontendMessageSASLResponse)
125134
test(_TestScramSha256MessageBuilders)

0 commit comments

Comments
 (0)