princepawn has asked for the wisdom of the Perl Monks concerning the following question:
# Before `make install' is performed this script should be runnable wi +th # `make test'. After `make install' it should work as `perl 1.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use warnings; use Test::More tests => 2; use SQL::AnyDBD; ######################### # Insert your test code below, the Test::More module is use()ed here s +o read # its man page ( perldoc Test::More ) for help writing this test scrip +t. ############################ ## get DB connection info ## ############################ unless ( $ENV{DBI_DSN} and $ENV{DBI_USER} and $ENV{DBI_PASS} ) { warn "A working DBI connection is required for the remaining tests +.\n"; warn "Please enter the following parameters (or pre-set in your EN +V):\n"; } sub get_line { warn " $_[0] (or accept default '$_[1]'): \n"; chomp( my $input = <STDIN> ); return length($input) ? $input : $_[1] } my $dsn = $ENV{DBI_DSN} || get_line(DBI_DSN => 'dbi:Pg:dbname=test') +; my $user = $ENV{DBI_USER} || get_line(DBI_USER => 'metaperl'); my $pass = $ENV{DBI_PASS} || get_line(DBI_PASS => ''); ###################### ## import test data ## ###################### my $dbh = DBI->connect($dsn, $user, $pass); die "Unable to connect to DB for testing!" unless $dbh; warn $dsn; my $rows_desired = 8; my $start_row = 4; my $sb = SQL::AnyDBD->new($dbh); my $sql = $sb->LIMIT(rows_desired => $rows_desired, start_row => $star +t_row); my %expect = ( Pg => [ 'LIMIT 8 OFFSET 4', 'LIMIT 8' ] ); my $driver = $dbh->{Driver}->{Name}; my $expect; sub next_expect { $expect = shift @ { $expect{$driver} } ; } next_expect; is ( $sql , $expect, 'LIMIT with rows_desired and start_row' ) ; $start_row = ''; next_expect; $sql = $sb->LIMIT(rows_desired => $rows_desired, start_row => $start_r +ow); is ( $sql , $expect, 'LIMIT with rows_desired no start_row passed' ) ;
~/hacks/SQL/AnyDBD $ make test /usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'bli +b/lib', 'blib/arch')" t/*.t t/1........ + t/1........ok 1/1 + t/1........ok t/limit....A working DBI connection is required for the remaining test +s. Please enter the following parameters (or pre-set in your ENV): DBI_DSN (or accept default 'dbi:Pg:dbname=test'): DBI_USER (or accept default 'metaperl'): DBI_PASS (or accept default ''): dbi:Pg:dbname=test at t/limit.t line 46, <STDIN> line 3. + t/limit....ok 1/2 + t/limit....ok 2/2 + t/limit....ok All tests successful. Files=2, Tests=3, 6 wallclock secs ( 0.26 cusr + 0.34 csys = 0.61 C +PU) ~/hacks/SQL/AnyDBD $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting Test::More test names to print out
by lachoy (Parson) on Dec 31, 2003 at 17:02 UTC | |
|
Re: getting Test::More test names to print out
by strider corinth (Friar) on Dec 31, 2003 at 17:54 UTC | |
|
Re: getting Test::More test names to print out
by hanenkamp (Pilgrim) on Dec 31, 2003 at 15:49 UTC | |
|
Re: getting Test::More test names to print out
by PodMaster (Abbot) on Jan 01, 2004 at 00:54 UTC | |
by princepawn (Parson) on Jan 03, 2004 at 10:34 UTC | |
by PodMaster (Abbot) on Jan 04, 2004 at 02:23 UTC | |
|
Re: getting Test::More test names to print out
by MidLifeXis (Monsignor) on Dec 31, 2003 at 20:00 UTC | |
|
Re: getting Test::More test names to print out
by DapperDan (Pilgrim) on Dec 31, 2003 at 22:12 UTC |