Codebase list libexception-class-dbi-perl / edfed5c
More thorough testing by using PurePerl. David Wheeler 21 years ago
1 changed file(s) with 26 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
00 #!/usr/bin/perl -w
11
2 # $Id: sth.t,v 1.3 2002/08/22 16:10:24 david Exp $
2 # $Id: sth.t,v 1.4 2002/08/23 18:26:26 david Exp $
33
44 use strict;
55 use Test::More (tests => 35);
66 BEGIN { use_ok('Exception::Class::DBI') }
7 BEGIN { $ENV{DBI_PUREPERL} = 2 }
78 use DBI;
89
9
10 #ok( my $dbh = DBI->connect('dbi:ExampleP:dummy', '', '',
11 ok( my $dbh = DBI->connect('dbi:Pg:dbname=template1', 'postgres', '',
10 ok( my $dbh = DBI->connect('dbi:ExampleP:dummy', '', '',
11 #ok( my $dbh = DBI->connect('dbi:Pg:dbname=template1', 'postgres', '',
1212 { PrintError => 0,
1313 RaiseError => 0,
1414 HandleError => Exception::Class::DBI->handler
2626 $sth->execute;
2727 };
2828
29 diag "Exception: $@";
30
3129 # Make sure we got the proper exception.
3230 ok( my $err = $@, "Get exception" );
3331 isa_ok( $err, 'Exception::Class::DBI' );
3432 isa_ok( $err, 'Exception::Class::DBI::H' );
3533 isa_ok( $err, 'Exception::Class::DBI::STH' );
3634
37 ok( $err->err == 7, "Check err" );
38 is( $err->errstr, 'ERROR: Relation "foo" does not exist',
35 ok( $err->err == 2, "Check err" );
36 is( $err->errstr, 'opendir(foo): No such file or directory',
3937 "Check errstr" );
40 is( $err->error,
41 'DBD::Pg::st execute failed: ERROR: Relation "foo" does not exist',
42 "Check error" );
38 is( $err->error, 'DBD::ExampleP::st execute failed: opendir(foo): No such '.
39 "file or directory\n", "Check error" );
4340 is( $err->state, 'S1000', "Check state" );
4441 ok( ! defined $err->retval, "Check retval" );
4542
4946 ok( $err->active_kids == 0, 'Check active_kids' );
5047 ok( ! $err->compat_mode, 'Check compat_mode' );
5148 ok( ! $err->inactive_destroy, 'Check inactive_destroy' );
52 ok( $err->trace_level == 0, 'Check trace_level' );
49
50 {
51 # PurePerl->{TraceLevel} should return an integer, but it doesn't.
52 local $^W;
53 ok( $err->trace_level == 0, 'Check trace_level' );
54 }
55
5356 is( $err->fetch_hash_key_name, 'NAME', 'Check fetch_hash_key_name' );
5457 ok( ! $err->chop_blanks, 'Check chop_blanks' );
5558 ok( $err->long_read_len == 80, 'Check long_read_len' );
5659 ok( ! $err->long_trunc_ok, 'Check long_trunc_ok' );
5760 ok( ! $err->taint, 'Check taint' );
58 ok( $err->num_of_fields == 0, 'Check num_of_fields' );
61 ok( $err->num_of_fields == 14, 'Check num_of_fields' );
5962 ok( $err->num_of_params == 0, 'Check num_of_params' );
6063 is( ref $err->field_names, 'ARRAY', "Check field_names" );
61 is( ref $err->type, 'ARRAY', "Check type" );
62 is( ref $err->precision, 'ARRAY', "Check precision" );
63 is( ref $err->scale, 'ARRAY', "Check scale" );
64
65 TODO: {
66 # These should be array refs, but ExampleP returns undef instead.
67 local $TODO = 'DBD::ExampleP should return references';
68 is( ref $err->type, 'ARRAY', "Check type" );
69 isa_ok( $err->precision, 'ARRAY', "Check precision" );
70 isa_ok( $err->scale, 'ARRAY', "Check scale" );
71 isa_ok( $err->param_values, 'HASH', "Check praram_values" );
72 }
73
6474 is( ref $err->nullable, 'ARRAY', "Check nullable" );
6575 ok( ! defined $err->cursor_name, "Check cursor_name" );
66 ok( ! defined $err->param_values, "Check praram_values" );
6776 is( $err->statement, 'select * from foo', 'Check statement' );
6877 ok( ! defined $err->rows_in_cache, "Check rows_in_cache" );