diff --git a/test/invoice_number_counter.sql b/test/invoice_number_counter.sql index 955c7a0..1bdaafe 100644 --- a/test/invoice_number_counter.sql +++ b/test/invoice_number_counter.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(27); +select plan(28); set search_path to numerus, auth, public; @@ -116,11 +116,19 @@ reset role; select lives_ok( $$ insert into invoice_number_counter (company_id, year, currval) - values (2, 2008, 0) + values (2, 2009, 0) $$, 'Should allow starting a counter from zero' ); +select throws_ok( $$ + insert into invoice_number_counter (company_id, year, currval) + values (2, 2008, -1) + $$, + '23514', 'new row for relation "invoice_number_counter" violates check constraint "counter_zero_or_positive"', + 'Should not allow starting a counter from a negative value' +); + select throws_ok( $$ insert into invoice_number_counter (company_id, year, currval) values (2, -2008, 1)