Crate pgtest[][src]

Expand description

pgtest is a Postgres wire protocol tester using datadriven test files. It can be used to send specific messages to any Postgres-compatible server and record received messages.

The following datadriven directives are supported:

  • send: Sends input messages to the server. Arguments, if needed, are specified using JSON. Refer to the associated types to see supported arguments. Arguments can be omitted to use defaults.
  • until: Waits until input messages have been received from the server. Additional messages are accumulated and returned as well.

During debugging, set the environment variable PGTEST_VERBOSE=1 to see messages sent and received.

Supported send types:

Supported until arguments:

  • no_error_fields causes ErrorResponse messages to have empty contents. Useful when none of our fields match Postgres. For example until no_error_fields.
  • err_field_typs specifies the set of error message fields (reference). For example: until err_field_typs=VC would return the severity and code fields in any ErrorResponse message.

For example, to execute a simple prepared statement:

send
Parse {"query": "SELECT $1::text, 1 + $2::int4"}
Bind {"values": ["blah", "4"]}
Execute
Sync
----

until
ReadyForQuery
----
ParseComplete
BindComplete
DataRow {"fields":["blah","5"]}
CommandComplete {"tag":"SELECT 1"}
ReadyForQuery {"status":"I"}

Structs

Functions