DBIx-Recordset

 view release on metacpan or  search on metacpan

test.pl  view on Meta::CPAN


        my $seq = DBIx::Recordset::FileSeq -> new (undef ,'test') ;
        
        if ($seq -> NextVal('foo') != 5)
            {
            printlog "ERROR in $lasttest: sequence value != 5\n" ;
            $errors++ ;
            }        
        elsif ($seq -> NextVal('foo') != 6)
            {
            printlog "ERROR in $lasttest: sequence value != 6\n" ;
            $errors++ ;
            }        
        if ($seq -> NextVal('bar') != 2)
            {
            printlog "ERROR in $lasttest: sequence value for bar != 2\n" ;
            $errors++ ;
            }        
        if ($seq -> NextVal('foo') != 7)
            {
            printlog "ERROR in $lasttest: sequence value != 7\n" ;
            $errors++ ;
            }        

        print "ok\n" if ($e == $errors) ;
        }



    #########################################################################################

     # cleanup
     if (!$nocleanup)
        {
        my  $dbh = DBIx::Recordset -> SetupObject ({'!DataSource' =>  $dbh,
                                                 '!Username' =>  $User, '!Password' =>  $Password
                                                });
        DropTestTables($dbh, @Table);
        $dbh->Disconnect;
        }

    #########################################################################################

    if ($errors)
        {
        print "\n$errors Errors detected for driver $Driver\n" ;
        }
    else
        {
        print "\nTests passed successfully for driver $Driver\n" ;
        }

    return $errors ;
    }

#########################################################################################


unlink "test.log" ;
unlink <test/seq.*> ;
chmod 0777, 'test' ; 
    
    open LOG, ">>test.log" or die "Cannot open test.log" ; 

    *DBIx::Recordset::LOG = \*LOG ; 
    $DBIx::Recordset::Debug = 5 ; 

    open (STDERR, ">&LOG") || die "Cannot redirect stderr" ;  
    #open (STDERR, ">dbi.log") || die "Cannot redirect stderr" ;  
    #DBI->trace(2) ;
    select (STDERR) ; $| = 1 ;
    select (LOG) ; $| = 1 ;
    select (STDOUT) ; $| = 1 ;



if ($#ARGV != -1)
    {
    eval { do $configfile ; } ;


    $Driver      = $ARGV[0] ;
    $DSN         = $ARGV[1] || $Drivers{$Driver}{dsn} ; 
    $User        = $ARGV[2] || $Drivers{$Driver}{user}  ;
    $Password    = $ARGV[3] || $Drivers{$Driver}{pass}  ;
    $nocleanup   = $ARGV[4] || 0 ;

    $> = $Drivers{$Driver}{uid} if (defined ($Drivers{$Driver}{uid})) ;
    $rc = DoTest ($Driver, $DSN, $User, $Password) ;
    $> = $< if ($Drivers{$Driver}{uid}) ;
    
    $fatal = 0 ;

    exit $rc ;
    }

do $configfile ;

@drivers = sort keys %Drivers ;


foreach $drv (@drivers)
    {
    $> = $Drivers{$drv}{uid} if (defined ($Drivers{$drv}{uid})) ;
    $errcnt {$drv} = DoTest ($drv, $Drivers{$drv}{dsn}, $Drivers{$drv}{user}, $Drivers{$drv}{pass}) ;
    $> = $< if ($Drivers{$drv}{uid}) ;
    }
     
$err = 0 ;
print "\nSummary:\n" ;

foreach $drv (@drivers)
    {
    if ($errcnt {$drv})
        {
        print "$errcnt{$drv} Errors detected for $drv\n" ;
        }
    else
        {
        print "Tests for $drv passed successfully\n" ;
        }



( run in 0.778 second using v1.01-cache-2.11-cpan-99c4e6809bf )