Changeset 138

Show
Ignore:
Timestamp:
06/16/08 17:36:19 (2 months ago)
Author:
ykerherve
Message:

Croak with a nice message id a driver cannot be found for a handle

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/TheSchwartz.pm

    r137 r138  
    7575        $driver = $client->{cached_drivers}{$hashdsn}{driver}; 
    7676    } else { 
    77         my $db = $client->{databases}{$hashdsn}; 
     77        my $db = $client->{databases}{$hashdsn} 
     78            or croak "Ouch, I don't know about a database whose hash is $hashdsn"; 
    7879        $driver = Data::ObjectDriver::Driver::DBI->new( 
    7980                dsn      => $db->{dsn}, 
  • trunk/t/api.t

    r124 r138  
    88 
    99use TheSchwartz; 
    10 use Test::More tests => 84
     10use Test::More tests => 108
    1111 
    1212run_tests(42, sub { 
     
    8282            $handle = $client->insert($job); 
    8383            isa_ok $handle, 'TheSchwartz::JobHandle'; 
     84             
     85            my $same = $client->lookup_job($handle->as_string); 
     86            ok $same; 
     87            isa_ok $same, 'TheSchwartz::Job'; 
     88            is $same->handle->as_string, $handle->as_string; 
     89             
     90        } 
     91         
     92        ## Just test that handles for unknown database croak with an explicit message 
     93        { 
     94            eval { $client->lookup_job( ("6a" x 16) ."-666") }; 
     95            ok $@ && unlike($@, qr/No Driver/) && like($@, qr/database.*hash/); 
    8496        } 
    8597