-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy path43prof_env.t
52 lines (38 loc) · 1.12 KB
/
43prof_env.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!perl -w
$|=1;
use strict;
#
# test script for using DBI_PROFILE env var to enable DBI::Profile
# and testing non-ref assignments to $h->{Profile}
#
BEGIN { $ENV{DBI_PROFILE} = 6 } # prior to use DBI
use DBI;
use DBI::Profile;
use Config;
use Data::Dumper;
BEGIN {
if ($DBI::PurePerl) {
print "1..0 # Skipped: profiling not supported for DBI::PurePerl\n";
exit 0;
}
}
use Test::More tests => 11;
DBI->trace(0, "STDOUT");
my $dbh1 = DBI->connect("dbi:ExampleP:", '', '', { RaiseError=>1 });
is(ref $dbh1->{Profile}, "DBI::Profile");
is(ref $dbh1->{Profile}{Data}, 'HASH');
is(ref $dbh1->{Profile}{Path}, 'ARRAY');
my $dbh2 = DBI->connect("dbi:ExampleP:", '', '', { RaiseError=>1 });
is(ref $dbh2->{Profile}, "DBI::Profile");
is(ref $dbh2->{Profile}{Data}, 'HASH');
is(ref $dbh2->{Profile}{Path}, 'ARRAY');
is $dbh1->{Profile}, $dbh2->{Profile}, '$h->{Profile} should be shared';
$dbh1->do("set dummy=1");
$dbh1->do("set dummy=2");
my $profile = $dbh1->{Profile};
my $p_data = $profile->{Data};
is keys %$p_data, 3; # '', $sql1, $sql2
ok $p_data->{''};
ok $p_data->{"set dummy=1"};
ok $p_data->{"set dummy=2"};
__END__