Skip to content

Possibility to access modifications inside test #365

Description

@floratmin

I have a test in which I have to access the modifications made in the function I want to test:

BEGIN;
SELECT '';
SELECT plan(1);

CREATE FUNCTION insert_email(_email text) RETURNS uuid AS $$
   INSERT INTO email (name, email_verification_token) VALUES (_email, gen_random_uuid) RETURNING email_verification_token;
$$ language sql;

SELECT is(insert_email('test@test.com'), (SELECT email_verification_token FROM email WHERE name = 'test@test.com'), 'Verification token is created');

SELECT * FROM finish();
ROLLBACK;

But if I test like this, the subquery for the assertion returns NULL. After the test, the record is created. I was wondering if there is any possibility of having access to the values created by the test in the assertion?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions