Show HN: Pg_yregress, Structured Testing for Postgres
github.com
github.com
One can tell IJ what's going on in one of two ways: comment markup or creating a JSON Schema for the yaml and placing x-intellij-language-injection metadata into the relevant elements
tests:
- #language=SQL
query: select 1 as result
results:
- result: 1
or $id: pg_yregress
$schema: "http://json-schema.org/draft-07/schema#"
properties:
tests:
type: array
items:
$ref: '#/definitions/Test'
definitions:
Test:
type: object
properties:
query:
description: the test query to run
type: string
# https://github.com/JetBrains/intellij-community/blob/idea/233.9802.14/json/src/jsonSchema/schema.json#L52
x-intellij-language-injection: SQL
results:
type: array
item:
type: object
additionalProperties: truePlus, it provides TAP output for test runners/printers that support it.
JSON is unambiguous and whitespace agnostic. There's only one way to do things. It's far more readable.
JSON as-is has fewer types and some things are better realized with the JSONNET way than stock.
Either way, JSON5 has been around for years and is a logical update because it brings parity with ECMAScript.
https://mit.cs.uchicago.edu/haohsiang/topics-auction/tree/02....
When I read "gbq enabled: yes" I don't worry about whether it's a string or a boolean when reading it, I worry about whether it's a string or a boolean when I want to change it and it gets parsed again.
2. Allows for organizing and structuring nested tests (providing organizational clarity)
3. Binary encoding testing (useful for new data types)
4. pg_yregress manages Postgres instances and their configuration
pgTAP has functionality that is not yet part of pg_yregress (vast library of helpers)
Ultimately, I believe both of these tools can coexist rather nicely. Would be great to integrate neatly.