Changeset 2154

Show
Ignore:
Timestamp:
04/29/08 22:54:19 (7 months ago)
Author:
mpaschal
Message:

Use more is_object/are_objects tests
Better test descriptions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-36/t/driver-tests.pl

    r2153 r2154  
    3030} 
    3131 
    32 use constant TESTS => 245
     32use constant TESTS => 261
    3333 
    3434use Test::More; 
     
    267267    direction => 'ascend', 
    268268    start_val => $foo[0]->created_on }); 
    269 isa_ok($tmp, 'Foo'); 
    270 is($tmp->id, $foo[1]->id, 'id'); 
     269is_object($tmp, $foo[1], 'Next newer Foo after Foo #1'); 
    271270 
    272271## Given the first Foo object, try to load the "previous" one 
     
    277276    direction => 'descend', 
    278277    start_val => $foo[0]->created_on }); 
    279 ok(!$tmp, 'no Foo'); 
     278ok(!$tmp, 'Search for next older Foo before Foo #1 found none'); 
    280279 
    281280## Given the second Foo object, try to load the "previous" one 
     
    286285    direction => 'descend', 
    287286    start_val => $foo[1]->created_on }); 
    288 isa_ok($tmp, 'Foo'); 
    289 is($tmp->id, $foo[0]->id, 'id'); 
     287is_object($tmp, $foo[0], 'Next older Foo before Foo #2'); 
    290288 
    291289## Given the second Foo object, try to load the "next" one 
    292 ## (the one with a larger created_on time). This should work
     290## (the one with a larger created_on time). This should fail
    293291$tmp = Foo->load(undef, { 
    294292    limit => 1, 
     
    296294    direction => 'ascend', 
    297295    start_val => $foo[1]->created_on }); 
    298 ok(!$tmp, 'no Foo'); 
     296ok(!$tmp, 'Search for next newer Foo after Foo #2 found none'); 
    299297 
    300298## Now, given the second Foo object's created_on - 1, try to 
     
    305303    direction => 'descend', 
    306304    start_val => $foo[1]->created_on-1 }); 
    307 isa_ok($tmp, 'Foo'); 
    308 is($tmp->id, $foo[0]->id, 'id'); 
     305is_object($tmp, $foo[0], 'Next older Foo before just before Foo #2'); 
    309306 
    310307## Now, given the second Foo object's created_on - 1, try to 
     
    315312    direction => 'ascend', 
    316313    start_val => $foo[1]->created_on-1 }); 
    317 isa_ok($tmp, 'Foo'); 
    318 is($tmp->id, $foo[1]->id, 'id'); 
     314is_object($tmp, $foo[1], 'Next newer Foo after just before Foo #2'); 
    319315 
    320316## Override created_on timestamp, make sure it works 
     
    322318$foo[1]->created_on($ts); 
    323319$foo[1]->save; 
     320 
    324321@tmp = Foo->load(undef, { 
    325322    sort => 'created_on', 
    326323    direction => 'descend', 
    327324    limit => 2 }); 
    328 is(@tmp, 2, 'array length 2'); 
    329 is($tmp[0]->id, 1, 'id'); 
    330 is($tmp[1]->id, 2, 'id'); 
     325are_objects(\@tmp, \@foo, 'Time-traveled Foos newest-first'); 
    331326 
    332327## Test limit of 2 with direction descend, but without 
     
    336331    direction => 'descend', 
    337332    limit => 2 }); 
    338 is(@tmp, 2, 'array length 2'); 
    339 is($tmp[0]->id, $foo[1]->id, 'id'); 
    340 is($tmp[1]->id, $foo[0]->id, 'id'); 
     333are_objects(\@tmp, [ reverse @foo ], 'Foos highest-id-first'); 
    341334 
    342335## Test loading using offset. 
     
    347340    limit => 1, 
    348341    offset => 1 }); 
    349 isa_ok($tmp, 'Foo'); 
    350 is($tmp->id, $foo[1]->id, 'id'); 
     342is_object($tmp, $foo[1], 'Second newest Foo'); 
    351343 
    352344## We only have 2 Foo objects, so this should load 
     
    357349    limit => 2, 
    358350    offset => 1 }); 
    359 is(@tmp, 1, 'array length 1'); 
    360 is($tmp[0]->id, $foo[1]->id, 'id'); 
     351are_objects(\@tmp, [ $foo[1] ], 'Second and third newest Foos'); 
    361352 
    362353## Should load the first Foo object (ascend with offset of 1). 
     
    366357    limit => 1, 
    367358    offset => 1 }); 
    368 isa_ok($tmp, 'Foo'); 
    369 is($tmp->id, 1, 'id'); 
     359is_object($tmp, $foo[0], 'Second oldest Foo'); 
    370360 
    371361## Now test join loads.