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

Assert sql exception to test constraints #827

Open
Markus- opened this issue Feb 6, 2025 · 0 comments
Open

Assert sql exception to test constraints #827

Markus- opened this issue Feb 6, 2025 · 0 comments

Comments

@Markus-
Copy link

Markus- commented Feb 6, 2025

Hi,

I want to know if it is possible to "catch" an error of the underlying database.

I have a database schema where I defined multiple types, constraints and other safeguards for data-integrity which I want to test through venom.

If I create a testcase to raise one of those exceptions the test failes and never returns a result as the code of the executor failes hard with the error message the underlying database driver gives.

Testcase "Query database", step #0-0: failed to exec command number 1: pq: cannot insert a non-DEFAULT value into column "dog_id" (test.yml:7)

I want to know how do I test such cases. I know the SQL will fail and I know the error message. Can I catch those errors and assert against them or do I have to be creative and write a simple database function which catches the error itself and returns plain sql-rows?

Regards
Markus

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

No branches or pull requests

1 participant