Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to test with snapshots #323

Open
S-Stanley opened this issue Oct 2, 2023 · 2 comments
Open

Allow to test with snapshots #323

S-Stanley opened this issue Oct 2, 2023 · 2 comments

Comments

@S-Stanley
Copy link

Hello guys,

I have to update many tests of SQL functions, and it's a tough work because, when we add/update/delete new columns, we have to update all the previous assertions, which is kind of a lot of work.

I was wondering if it was possible to add snapshot feature, similar to what you can find on javascript testing library like jest toMatchSnapshot.

For example, now we are testing like this:

SELECT results_eq(
    $$
        SELECT
            column_name
        FROM
            table_name
    $$,
    $$
        VALUES(
            'x'
        ), (
            'y'
        ), (
            '42'
        )
    $$,
    'Assert that...'
)

And using snapshots it would be for example

SELECT snapshot_equal(
    $$
        SELECT
            column_name
        FROM
            table_name
    $$,
    'Assert that...'
)
@theory
Copy link
Owner

theory commented Oct 2, 2023

Where would it store the snapshot?

@ewie
Copy link
Contributor

ewie commented Oct 15, 2023

This sounds like the regression testing in Postgres: comparing the output of psql scripts to the stored expected output.

pgTAP could implement something similar using temporary tables and \copy for loading the snapshot data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants