TestBuilder should not generate datetime for date columns, but only for
datetime and timestamp columns.
Test plan:
Make sure the change in t/db_dependent/TestBuilder.t are consistent.
Before this patch, 1 of the 2 tests should fail.
After this patch applied, they both should pass.
Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
use Modern::Perl;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::Warn;
use Data::Dumper qw(Dumper);
'Build should not overwrite an auto_incr column';
};
+subtest 'Date handling' => sub {
+ plan tests => 2;
+
+ $builder = t::lib::TestBuilder->new;
+
+ my $patron = $builder->build( { source => 'Borrower' } );
+ is( length( $patron->{updated_on} ), 19, 'A timestamp column value should be YYYY-MM-DD HH:MM:SS' );
+ is( length( $patron->{dateofbirth} ), 10, 'A date column value should be YYYY-MM-DD' );
+
+};
+
$schema->storage->txn_rollback;
1;
decimal => \&_gen_real,
double_precision => \&_gen_real,
- timestamp => \&_gen_date,
- datetime => \&_gen_date,
+ timestamp => \&_gen_datetime,
+ datetime => \&_gen_datetime,
date => \&_gen_date,
char => \&_gen_text,
sub _gen_date {
my ($self, $params) = @_;
+ return $self->schema->storage->datetime_parser->format_date(DateTime->now())
+}
+
+sub _gen_datetime {
+ my ($self, $params) = @_;
return $self->schema->storage->datetime_parser->format_datetime(DateTime->now());
}