diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-09-24 10:15:50 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-26 13:46:46 +0000 |
commit | 485b97be9f2f2abf5a40923b5fd85f75714a8c02 (patch) | |
tree | ca05cb0ecf3828d909a898c3e5805804a0aff5f8 /t/07_error.t | |
download | perl-dbd-sqlite-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/perl-dbd-sqlite-tarball/DBD-SQLite-1.38_01.tar.gz.HEADDBD-SQLite-1.38_01masterbaserock/morph
Diffstat (limited to 't/07_error.t')
-rw-r--r-- | t/07_error.t | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/07_error.t b/t/07_error.t new file mode 100644 index 0000000..68ea9ca --- /dev/null +++ b/t/07_error.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test; +use Test::More tests => 8; +use Test::NoWarnings; + +my $dbh = connect_ok( RaiseError => 1, PrintError => 0 ); +eval { + $dbh->do('ssdfsdf sdf sd sdfsdfdsf sdfsdf'); +}; +ok($@, 'Statement 1 generated an error'); +is( $DBI::err, 1, '$DBI::err ok' ); +is( $DBI::errstr, 'near "ssdfsdf": syntax error', '$DBI::errstr ok' ); + +$dbh->do('create table testerror (a, b)'); +$dbh->do('insert into testerror values (1, 2)'); +$dbh->do('insert into testerror values (3, 4)'); + +$dbh->do('create unique index testerror_idx on testerror (a)'); +eval { + $dbh->do('insert into testerror values (1, 5)'); +}; +ok($@, 'Statement 2 generated an error'); +is( $DBI::err, 19, '$DBI::err ok' ); +like( $DBI::errstr, qr/column a is not unique/, '$DBI::errstr ok' ); |