Changeset 2462

Show
Ignore:
Timestamp:
05/29/08 21:17:29 (21 months ago)
Author:
mpaschal
Message:

Test index generation and introspection

Files:
1 modified

Legend:

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

    r2404 r2462  
    3232} 
    3333 
    34 plan tests => 30; 
     34plan tests => 41; 
    3535 
    3636 
     
    6464    }, 
    6565    indexes => { 
    66         name       => 1, 
    67         status     => 1, 
    68         created_on => 1, 
     66        string_25_nn => 1, 
     67        int_small_nn => 1, 
     68        string_dt  => { 
     69            columns => [ qw( string_25 datetime_nn ) ], 
     70        }, 
    6971    }, 
    7072    audit       => 1, 
     
    163165is_def($defs->{datetime_nn},  _def(0, 1, 'datetime'),     'Ddltest datetime_nn column def is correct'); 
    164166 
    165     # audit fields 
     167# audit fields 
    166168is_def($defs->{created_on},  _def(0, 0, 'datetime'), 'Ddltest created_on column def is correct'); 
    167169is_def($defs->{created_by},  _def(0, 0, 'integer'),  'Ddltest created_by column def is correct'); 
     
    169171is_def($defs->{modified_by}, _def(0, 0, 'integer'),  'Ddltest modified_by column def is correct'); 
    170172 
     173 
     174ok(!defined MT::Object->driver->dbd->ddl_class->index_defs('Ddltest'), q{Ddltest table's indexes are not yet created}); 
     175 
     176my @index_sql = $ddl_class->index_table_sql('Ddltest'); 
     177ok(@index_sql, 'Index Table SQL for Ddltest is available'); 
     178is(scalar @index_sql, 3, 'Index Table SQL has 4 statements'); 
     179for my $index_sql (@index_sql) { 
     180    $res = $dbh->do($index_sql); 
     181    ok($res, 'Driver could perform Index Table SQL for Ddltest'); 
     182    if (!$res) { 
     183        diag($dbh->errstr || $DBI::errstr); 
     184        diag('SQL: ' . $index_sql); 
     185    } 
     186} 
     187 
     188my $index_defs = MT::Object->driver->dbd->ddl_class->index_defs('Ddltest'); 
     189ok($index_defs, 'Ddltest table has index defs'); 
     190 
     191is(keys %$index_defs, 3, 'Ddltest table has three indexes'); 
     192is($index_defs->{string_25_nn}, 1, 'Ddltest table has name index'); 
     193is($index_defs->{int_small_nn}, 1, 'Ddltest table has status index'); 
     194is_deeply($index_defs->{string_dt}, { columns => [ qw( string_25 datetime_nn ) ] }, 'Ddltest table has multi-column string_dt index'); 
     195 
    1711961; 
    172197