/[A3C]/t/20-sql.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /t/20-sql.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 145 - (show annotations)
Sat May 31 16:30:09 2008 UTC (14 years, 1 month ago) by dpavlin
File MIME type: application/x-troff
File size: 875 byte(s)
Added dbh accessor to support connecting to any database
1 #!/usr/bin/env perl
2 use warnings;
3 use strict;
4
5 =head1 DESCRIPTION
6
7 test SQL module
8
9 =cut
10
11 use Jifty::Test tests => 18;
12
13 use_ok('A3C::SQL');
14 use_ok('DBI');
15
16 my $query = 'select 42 as nr';
17
18 ok( my $sql = A3C::SQL->new({ query => $query }), 'new' );
19
20 isa_ok( $sql, 'A3C::SQL' );
21 is( $sql->query, $query, 'sql' );
22
23 cmp_ok( $sql->count, '==', 1, 'count' );
24
25 ok( my $row = $sql->next, 'next' );
26
27 isa_ok( $row, 'A3C::SQL::row' );
28
29 ok( $row->nr, 'row has accessor' );
30
31 diag $row->nr;
32 is( $row->nr, 42, 'nr' );
33
34 ok( ! $sql->next, 'last row' );
35
36 ok( my $dbh = DBI->connect( 'DBI:Pg:dbname=template1' ), 'dbh' );
37 ok( my $sql = A3C::SQL->new({ query => "select 5 as nr", dbh => $dbh }), 'new' );
38 cmp_ok( $sql->count, '==', 1, 'count' );
39 ok( my $row2 = $sql->next, 'next' );
40 isa_ok( $row2, 'A3C::SQL::row' );
41 ok( $row2->nr, 'row has accessor' );
42 diag $row2->nr;
43 is( $row2->nr, 5, 'nr' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26