Skip Menu |

This queue is for tickets about the Test-MockDBI CPAN distribution.

Report information
The Basics
Id: 40296
Status: resolved
Priority: 0/
Queue: Test-MockDBI

People
Owner: Nobody in particular
Requestors: aff [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.61
Fixed in: 0.62

Attachments


Subject: Allow errstr to be set at runtime
I want to use Test::MockDBI to test modules that checks the value of DBI->errstr. The attached patch adds a function 'set_errstr()' to MockDBI.pm that allows the value of DBI->errstr to be set at runtime. Below is an example of how it can be used: $ cat errstr.pl # errstr.pl use warnings; use strict; BEGIN { push @ARGV, "--dbitest=42"; } use Test::More qw(no_plan); use Test::MockDBI; my $mock_dbi = Test::MockDBI::get_instance(); cmp_ok($mock_dbi->get_dbi_test_type(), q[==], 42, q{Expect test type 42}); # ------ set errstr to true $mock_dbi->set_errstr('sql failed at line 53'); my $dbh = DBI->connect(); my $sth = $dbh->prepare('select foo from bar'); is($sth->errstr, 'sql failed at line 53', q{expect sth->errstr to be defined}); ($sth, $dbh) = (undef, undef); # ------ set errstr to false $mock_dbi->set_errstr(); $dbh = DBI->connect(); $sth = $dbh->prepare('select foo from bar'); ok(!$sth->errstr, q{expect sth->errstr to be undefined}); __END__ $ prove errstr.pl errstr....ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.02 cusr 0.00 csys = 0.05 CPU) Result: PASS
Subject: mockdbi.errstr.patch.tar.gz
Download mockdbi.errstr.patch.tar.gz
application/x-gzip 1.2k

Message body not shown because it is not plain text.

From: aff [...] cpan.org
Resolved in Test::MockDBI 0.62