summaryrefslogtreecommitdiff
path: root/t/43-dbtest.t
blob: bb286d26f827b80e42212a75db25db9907d1ae96 (plain)
  1. use Test::More;
  2. use strict;
  3. if (!defined $ENV{LSMB_TEST_DB}){
  4. plan skip_all => 'Skipping all. Told not to test db.';
  5. }
  6. else {
  7. plan tests => 51;
  8. if (defined $ENV{LSMB_NEW_DB}){
  9. $ENV{PGDATABASE} = $ENV{LSMB_NEW_DB};
  10. }
  11. if (!defined $ENV{PGDATABASE}){
  12. die "We were told to run tests, but no database specified!";
  13. }
  14. }
  15. my @testscripts = qw(Account Business_type Company Draft Payment
  16. Session Voucher);
  17. chdir 'sql/modules/test/';
  18. for my $testscript (@testscripts){
  19. open (TEST, '-|', "psql -f $testscript.sql");
  20. my @testlines = grep /\|\s+(t|f)\s?$/, <TEST>;
  21. cmp_ok(scalar @testlines, '>', 0, "$testscript.sql returned test results");
  22. for my $test (@testlines){
  23. my @parts = split /\|/, $test;
  24. like($parts[1], qr/t\s?$/, $parts[0]);
  25. }
  26. }