X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F02-schema.t;fp=t%2F02-schema.t;h=5ce4a09fdabda0139ce09f92e7f5a3cd86793fde;hb=3be80851db62c6123d1430f321b5d9a47ee31379;hp=64e6cbb07960487b6b43ce78b218e94949475c94;hpb=8857ad7362d0849cfba9aae280565f92936cfc43;p=dbsrgits%2FDBIx-Class-DateTime-Epoch.git diff --git a/t/02-schema.t b/t/02-schema.t index 64e6cbb..5ce4a09 100644 --- a/t/02-schema.t +++ b/t/02-schema.t @@ -3,7 +3,7 @@ use warnings; use lib 't/lib'; -use Test::More tests => 16; +use Test::More tests => 19; use DBICx::TestDatabase; use DateTime; @@ -15,32 +15,35 @@ my $rs = $schema->resultset( 'Foo' ); my $now = DateTime->now; my $epoch = $now->epoch; - $schema->populate( 'Foo', [ [ qw( id bar baz creation_time modification_time ) ], [ 1, ( $epoch ) x 4 ] ] ); + $schema->populate( 'Foo', [ [ qw( id bar baz creation_time modification_time dt ) ], [ 1, ( $epoch ) x 4, $now ] ] ); { my $row = $rs->find( 1 ); isa_ok( $row->bar, 'DateTime' ); isa_ok( $row->baz, 'DateTime' ); + isa_ok( $row->dt, 'DateTime' ); ok( $row->bar == $now, 'inflate: epoch as int' ); ok( $row->baz == $now, 'inflate: epoch as varchar' ); + ok( $row->dt == $now, 'inflate: regular datetime column' ); } { - $rs->create( { bar => $now, baz => $now } ); + $rs->create( { bar => $now, baz => $now, dt => $now } ); my $row = $rs->find( 2 ); isa_ok( $row->bar, 'DateTime' ); isa_ok( $row->baz, 'DateTime' ); + isa_ok( $row->dt, 'DateTime' ); is( $row->get_column( 'bar' ), $epoch, 'deflate: epoch as int' ); is( $row->get_column( 'baz' ), $epoch, 'deflate: epoch as varchar' ); + is( $row->get_column( 'dt' ), join( ' ', $now->ymd, $now->hms ), 'deflate: regular datetime column' ); # courtesy of TimeStamp isa_ok( $row->creation_time, 'DateTime' ); # courtesy of TimeStamp isa_ok( $row->modification_time, 'DateTime' ); like( $row->get_column( 'creation_time' ), qr/^\d+$/, 'TimeStamp as epoch' ); like( $row->get_column( 'modification_time' ), qr/^\d+$/, 'TimeStamp as epoch' ); - like( $row->get_column( 'update_time' ), qr/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/, 'TimeStamp still Timestamp' ); my $mtime = $row->modification_time; sleep( 1 );