Changeset 2539

Show
Ignore:
Timestamp:
06/10/08 22:17:13 (20 months ago)
Author:
mpaschal
Message:

Describe tests better
Use are_objects() where applicable to remove superfluous 'tests'
BugzID: 79952

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-39/t/driver-tests.pl

    r2534 r2539  
    3333} 
    3434 
    35 plan tests => 197; 
     35plan tests => 186; 
    3636 
    3737package Zot; 
     
    469469                { unique => 1, 
    470470                  sort => 'created_on', 
    471                   direction => 'descend', } ] }), 2, 'count7'); 
     471                  direction => 'descend', } ] }), 2, 'There are 2 unique Foos associated with Bars'); 
    472472 
    473473## Now load all Foo objects in order of most recently 
     
    479479                  direction => 'descend', 
    480480                  unique => 1 } ] }); 
    481 is(@tmp, 2, 'array length 2'); 
    482 is($tmp[0]->id, $foo[0]->id, 'id'); 
    483 is($tmp[1]->id, $foo[1]->id, 'id'); 
     481are_objects(\@tmp, \@foo, 'unique Foos associated with Bars, oldest first'); 
    484482 
    485483## Load all Foo objects in order of most recently 
     
    490488                { sort => 'created_on', 
    491489                  direction => 'descend', } ] }); 
    492 is(@tmp, 3, 'array length 3'); 
    493 is($tmp[0]->id, $foo[0]->id, 'id'); 
    494 is($tmp[1]->id, $foo[1]->id, 'id'); 
    495 is($tmp[2]->id, $foo[1]->id, 'id'); 
     490are_objects(\@tmp, [ @foo, $foo[1] ], 'Foos associated with Bars, oldest first'); 
    496491 
    497492## Load last 1 Foo object in order of most recently 
     
    504499                  unique => 1, 
    505500                  limit => 1, } ] }); 
    506 is(@tmp, 1, 'array length 1 with join'); 
    507 is($tmp[0]->id, $foo[0]->id, 'id'); 
     501are_objects(\@tmp, [ $foo[0] ], 'Foos associated with oldest Bar'); 
    508502 
    509503## Load all Foo objects where Bar.name = 'bar0' 
     
    514508                  direction => 'descend', 
    515509                  unique => 1, } ] }); 
    516 is(@tmp, 1, 'array length 1 with join, limit by name'); 
    517 is($tmp[0]->id, $foo[1]->id, 'id'); 
     510are_objects(\@tmp, [ $foo[1] ], 'Foos associated with Bars named bar0'); 
    518511 
    519512## foo[1] is older than foo[0] because we overrode the timestamp, 
     
    522515    { sort => 'created_on', direction => 'descend', limit => 1, 
    523516    join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 
    524 is(@tmp, 1, 'array length 1'); 
    525 is($tmp[0]->id, $foo[0]->id, 'id'); 
     517are_objects(\@tmp, [ $foo[0] ], 'One Foo associated with Bars of status=0'); 
    526518 
    527519## This is the same join as the last one, but without the limit--so 
     
    530522    { sort => 'created_on', direction => 'descend', 
    531523      join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 
    532 is(@tmp, 2, 'array length 2'); 
    533 is($tmp[0]->id, $foo[0]->id, 'id'); 
    534 is($tmp[1]->id, $foo[1]->id, 'id'); 
     524are_objects(\@tmp, \@foo, 'All Foos associated with Bars of status=0'); 
    535525 
    536526## Filter join results by providing a value for 'status'; only Foo[0] 
     
    539529    { sort => 'created_on', direction => 'descend', 
    540530      join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 
    541 is(@tmp, 1, 'array length 1'); 
    542 is($tmp[0]->id, $foo[0]->id, 'id'); 
     531are_objects(\@tmp, [ $foo[0] ], 'Foos of status=2 associated with Bars of status=0'); 
    543532 
    544533# Join across a column. 
     
    554543 
    555544## TEST EXISTS METHOD 
    556 ok($foo[0]->exists, 'exists'); 
     545ok($foo->exists, 'First Foo long saved exists in db'); 
    557546$tmp = Foo->new; 
    558 ok(!$tmp->exists, 'does not exist'); 
     547ok(!$tmp->exists, 'New Foo just created does not exist in db'); 
    559548$tmp->id(5); 
    560 ok(!$tmp->exists, 'does not exist'); 
     549ok(!$tmp->exists, 'New Foo just created with fake id does not exist in db'); 
    561550 
    562551## Change foo[1]->status so that its value is unique (for index)