/[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 159 - (show annotations)
Sun Jun 15 14:40:50 2008 UTC (14 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1035 byte(s)
added _column_names accessor to A3C::SQL
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 => 20;
12
13 use Data::Dump qw/dump/;
14
15 use_ok('A3C::SQL');
16 use_ok('DBI');
17
18 my $query = 'select 42 as nr';
19
20 ok( my $sql = A3C::SQL->new({ query => $query }), 'new' );
21
22 isa_ok( $sql, 'A3C::SQL' );
23 is( $sql->query, $query, 'sql' );
24
25 cmp_ok( $sql->count, '==', 1, 'count' );
26
27 ok( my $row = $sql->next, 'next' );
28
29 isa_ok( $row, 'A3C::SQL::row' );
30
31 ok( $row->nr, 'row has accessor' );
32
33 diag $row->nr;
34 is( $row->nr, 42, 'nr' );
35
36 ok( ! $sql->next, 'last row' );
37
38 ok( my $dbh = DBI->connect( 'DBI:Pg:dbname=template1' ), 'dbh' );
39 ok( my $sql = A3C::SQL->new({ query => "select 5 as nr", dbh => $dbh }), 'new' );
40 cmp_ok( $sql->count, '==', 1, 'count' );
41 is_deeply( [ $sql->_column_names ], [ 'nr' ], '_column_names' );
42 is_deeply( scalar $sql->_column_names, 1, 'scalar _column_names' );
43 ok( my $row2 = $sql->next, 'next' );
44 isa_ok( $row2, 'A3C::SQL::row' );
45 ok( $row2->nr, 'row has accessor' );
46 diag $row2->nr;
47 is( $row2->nr, 5, 'nr' );
48

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26