Skip to content

Instantly share code, notes, and snippets.

@apolishch
Created August 13, 2019 15:25
Show Gist options
  • Save apolishch/73edfce2ef8171e09a8aed1a3f11bd00 to your computer and use it in GitHub Desktop.
Save apolishch/73edfce2ef8171e09a8aed1a3f11bd00 to your computer and use it in GitHub Desktop.
Advanced Schema Tests
BEGIN;
SELECT plan(2);
INSERT INTO payments(1, 99, 'failed');
PREPARE insert_failure AS
INSERT INTO payments VALUES(10, -7, 'failed');
PREPARE second_failure AS
INSERT INTO policies VALUES(11, 1, 'annual');
SELECT throws_ok(
'insert_failure',
'23514',
'new row for relation "payments" violates check constraint "amount_less_than_0"'
);
SELECT throws_ok(
'second_failure',
'P0001',
'can only bind succeeded payments'
);
SELECT * FROM finish();
ROLLBACK;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment