From: Brian Cassidy Date: Tue, 18 Jan 2011 19:36:39 +0000 (-0400) Subject: slightly different testing strategy X-Git-Tag: 0.07~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3be80851db62c6123d1430f321b5d9a47ee31379;p=dbsrgits%2FDBIx-Class-DateTime-Epoch.git slightly different testing strategy --- 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 ); diff --git a/t/lib/MySchema/Foo.pm b/t/lib/MySchema/Foo.pm index e98fcc5..b1cdb3a 100644 --- a/t/lib/MySchema/Foo.pm +++ b/t/lib/MySchema/Foo.pm @@ -27,6 +27,10 @@ __PACKAGE__->add_columns( size => 50, inflate_datetime => 'epoch', }, + dt => { # regular datetime field -- should not conflict + data_type => 'datetime', + inflate_datetime => 1, + }, # working in conjunction with DBIx::Class::TimeStamp creation_time => { data_type => 'bigint', @@ -38,14 +42,7 @@ __PACKAGE__->add_columns( inflate_datetime => 1, set_on_create => 1, set_on_update => 1, - }, - update_time => { - data_type => 'datetime', - set_on_create => 1, - set_on_update => 1, - is_nullable => 1, - }, - + } ); __PACKAGE__->set_primary_key( 'id' );