14_progress_handler.t [plain text]
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
use t::lib::Test qw/connect_ok @CALL_FUNCS/;
use Test::More;
use Test::NoWarnings;
plan tests => 5 * @CALL_FUNCS + 1;
my $N_OPCODES = 50;
my $n_callback = 0;
sub progress_handler {
$n_callback += 1;
return 0;
}
foreach my $call_func (@CALL_FUNCS) {
$n_callback = 0;
my $dbh = connect_ok( RaiseError => 1 );
ok($dbh->$call_func( $N_OPCODES, \&progress_handler, "progress_handler" ));
$dbh->do( 'CREATE TEMP TABLE progress_test ( foo )' );
$dbh->begin_work;
for my $count (1 .. 1000) {
my $rand = rand;
$dbh->do( "INSERT INTO progress_test(foo) VALUES ( $rand )" );
}
$dbh->commit;
my $result = $dbh->do( "SELECT * from progress_test ORDER BY foo " );
ok($n_callback);
ok($dbh->$call_func( $N_OPCODES, undef, "progress_handler" ));
$n_callback = 0;
$result = $dbh->do( "SELECT * from progress_test ORDER BY foo DESC " );
ok(!$n_callback);
$dbh->disconnect;
}