X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100populate.t;h=2817e5b2b84eedcf1b6447bd6a7e6e871d042e31;hb=HEAD;hp=e7cb830886c6becf2c65f527ed102ce3a257f8ca;hpb=2a6dda4b4b591e4da531d6c78ff9dc9e359d5fd9;p=dbsrgits%2FDBIx-Class.git diff --git a/t/100populate.t b/t/100populate.t index e7cb830..2817e5b 100644 --- a/t/100populate.t +++ b/t/100populate.t @@ -1,16 +1,30 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; use Test::Warn; -use lib qw(t/lib); + use DBICTest; -use DBIx::Class::_Util 'sigwarn_silencer'; -use Path::Class::File (); +use DBIx::Class::_Util qw(sigwarn_silencer serialize); use Math::BigInt; use List::Util qw/shuffle/; -use Storable qw/nfreeze dclone/; + +{ + package DBICTest::StringifiesOnly; + use overload + '""' => sub { $_[0]->[0] }, + fallback => 0, + ; +} +{ + package DBICTest::StringifiesViaFallback; + use overload + 'bool' => sub { $_[0]->[0] }, + ; +} my $schema = DBICTest->init_schema(); @@ -383,15 +397,14 @@ lives_ok { } 'literal+bind with semantically identical attrs works after normalization'; # test all kinds of population with stringified objects +# or with empty sets warnings_like { - local $ENV{DBIC_RT79576_NOWARN}; - my $rs = $schema->resultset('Artist')->search({}, { columns => [qw(name rank)], order_by => 'artistid' }); # the stringification has nothing to do with the artist name # this is solely for testing consistency - my $fn = Path::Class::File->new ('somedir/somefilename.tmp'); - my $fn2 = Path::Class::File->new ('somedir/someotherfilename.tmp'); + my $fn = bless [ 'somedir/somefilename.tmp' ], 'DBICTest::StringifiesOnly'; + my $fn2 = bless [ 'somedir/someotherfilename.tmp' ], 'DBICTest::StringifiesViaFallback'; my $rank = Math::BigInt->new(42); my $args = { @@ -438,19 +451,29 @@ warnings_like { [qw( rank name )], [ $rank, $fn ], ]}, + + 'empty set' => { AoA => [ + [qw( name rank )], + ]}, }; # generate the AoH equivalent based on the AoAs above + # also generate the expected HRI output ( is_deeply is too smart for its own good ) for my $bag (values %$args) { + $bag->{AoH} = []; + $bag->{Expected} = []; my @hdr = @{$bag->{AoA}[0]}; for my $v ( @{$bag->{AoA}}[1..$#{$bag->{AoA}}] ) { push @{$bag->{AoH}}, my $h = {}; @{$h}{@hdr} = @$v; + + push @{$bag->{Expected}}, my $hs = {}; + @{$hs}{@hdr} = map { "$_" } @$v; } } local $Storable::canonical = 1; - my $preimage = nfreeze($args); + my $preimage = serialize($args); for my $tst (keys %$args) { @@ -461,7 +484,7 @@ warnings_like { $rs->populate($args->{$tst}{$type}); is_deeply( $rs->all_hri, - $args->{$tst}{AoH}, + $args->{$tst}{Expected}, "Populate() $tst in void context" ); @@ -470,7 +493,7 @@ warnings_like { my $dummy = $rs->populate($args->{$tst}{$type}); is_deeply( $rs->all_hri, - $args->{$tst}{AoH}, + $args->{$tst}{Expected}, "Populate() $tst in non-void context" ); @@ -479,7 +502,7 @@ warnings_like { my @dummy = $rs->populate($args->{$tst}{$type}); is_deeply( $rs->all_hri, - $args->{$tst}{AoH}, + $args->{$tst}{Expected}, "Populate() $tst in non-void context" ); } @@ -490,29 +513,18 @@ warnings_like { is_deeply( $rs->all_hri, - $args->{$tst}{AoH}, + $args->{$tst}{Expected}, "Create() $tst" ); } ok ( - ($preimage eq nfreeze($args)), + ($preimage eq serialize($args)), 'Arguments fed to populate()/create() unchanged' ); $rs->delete; -} [ - # warning to be removed around Apr 1st 2015 - # smokers start failing a month before that - ( - ( DBICTest::RunMode->is_author and ( time() > 1427846400 ) ) - or - ( DBICTest::RunMode->is_smoker and ( time() > 1425168000 ) ) - ) - ? () - # one unique for populate() and create() each - : (qr/\QPOSSIBLE *PAST* DATA CORRUPTION detected \E.+\QTrigger condition encountered at @{[ __FILE__ ]} line\E \d/) x 4 -], 'Data integrity warnings as planned'; +} [], 'Data integrity warnings gone as planned'; $schema->is_executed_sql_bind( sub {