From: Peter Rabbitson Date: Wed, 20 Mar 2013 06:52:05 +0000 (+0100) Subject: space-compress tests making them readable - no changes X-Git-Tag: v0.08250~31^2~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3d3e99db7a4feb8cc1d7523995a90f6c76e230ff;p=dbsrgits%2FDBIx-Class.git space-compress tests making them readable - no changes --- diff --git a/t/inflate/hri_torture.t b/t/inflate/hri_torture.t index 5c5e505..92aa2d8 100644 --- a/t/inflate/hri_torture.t +++ b/t/inflate/hri_torture.t @@ -77,32 +77,16 @@ cmp_deeply order_by => [qw/me.cdid artist.artistid/], })->all ], [ - { - single_track => undef, - year => 1981 - }, - { - single_track => undef, - year => 1976 - }, - { - single_track => { - cd => { - artist => { - name => "JMJ" - } - } + { year => 1981, single_track => undef }, + { year => 1976, single_track => undef }, + { year => 1978, single_track => { + cd => { + artist => { name => "JMJ" } }, - year => 1978 - }, - { - single_track => undef, - year => 1977 - }, - { - single_track => undef, - year => 1977 - }, + }}, + { year => 1977, single_track => undef }, + { year => 1977, single_track => undef }, + ], 'plain 1:1 descending chain ' . $rs->result_class ; @@ -122,222 +106,155 @@ cmp_deeply })->all ], [ { - artist => 1, - single_track => undef, - title => "Magnetic Fields", - year => 1981 + artist => 1, title => "Magnetic Fields", year => 1981, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "Oxygene", - year => 1976 + artist => 1, title => "Oxygene", year => 1976, single_track => undef, }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m1" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m2" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m3" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 1, - tracks => { + artistid => 1, cds => { + cdid => 1, tracks => { title => "m4" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 2, - tracks => { + artistid => 1, cds => { + cdid => 2, tracks => { title => "o2" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 2, - tracks => { + artistid => 1, cds => { + cdid => 2, tracks => { title => "o1" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 3, - tracks => { + artistid => 1, cds => { + cdid => 3, tracks => { title => "e1" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 3, - tracks => { + artistid => 1, cds => { + cdid => 3, tracks => { title => "e2" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 3, - tracks => { + artistid => 1, cds => { + cdid => 3, tracks => { title => "e3" } } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 4, - tracks => undef + artistid => 1, cds => { + cdid => 4, tracks => undef } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => { - cdid => 5, - tracks => undef + artistid => 1, cds => { + cdid => 5, tracks => undef } } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => undef, - title => "fuzzy_1", - year => 1977 + artist => 1, title => "fuzzy_1", year => 1977, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "fuzzy_2", - year => 1977 + artist => 1, title => "fuzzy_2", year => 1977, single_track => undef, } ], 'non-collapsing 1:1:1:M:M chain ' . $rs->result_class, @@ -359,92 +276,53 @@ cmp_deeply })->all ], [ { - artist => 1, - single_track => undef, - title => "Magnetic Fields", - year => 1981 + artist => 1, title => "Magnetic Fields", year => 1981, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "Oxygene", - year => 1976 + artist => 1, title => "Oxygene", year => 1976, single_track => undef, }, { - artist => 1, - single_track => { + artist => 1, title => "Equinoxe", year => 1978, single_track => { cd => { artist => { - artistid => 1, - cds => [ + artistid => 1, cds => [ { - cdid => 1, - tracks => [ - { - title => "m1" - }, - { - title => "m2" - }, - { - title => "m3" - }, - { - title => "m4" - } + cdid => 1, tracks => [ + { title => "m1" }, + { title => "m2" }, + { title => "m3" }, + { title => "m4" }, ] }, { - cdid => 2, - tracks => [ - { - title => "o2" - }, - { - title => "o1" - } + cdid => 2, tracks => [ + { title => "o2" }, + { title => "o1" }, ] }, { - cdid => 3, - tracks => [ - { - title => "e1" - }, - { - title => "e2" - }, - { - title => "e3" - } + cdid => 3, tracks => [ + { title => "e1" }, + { title => "e2" }, + { title => "e3" }, ] }, { - cdid => 4, - tracks => [] + cdid => 4, tracks => [], }, { - cdid => 5, - tracks => [] + cdid => 5, tracks => [], } ] } } }, - title => "Equinoxe", - year => 1978 }, { - artist => 1, - single_track => undef, - title => "fuzzy_1", - year => 1977 + artist => 1, title => "fuzzy_1", year => 1977, single_track => undef, }, { - artist => 1, - single_track => undef, - title => "fuzzy_2", - year => 1977 + artist => 1, title => "fuzzy_2", year => 1977, single_track => undef, } ], 'collapsing 1:1:1:M:M chain ' . $rs->result_class, diff --git a/t/prefetch/false_colvalues.t b/t/prefetch/false_colvalues.t index 4520bf4..5213e73 100644 --- a/t/prefetch/false_colvalues.t +++ b/t/prefetch/false_colvalues.t @@ -7,22 +7,12 @@ use Test::Deep; use lib qw(t/lib); use DBICTest; -my $schema = DBICTest->init_schema( - no_populate => 1, -); +my $schema = DBICTest->init_schema( no_populate => 1 ); $schema->resultset('CD')->create({ - cdid => 0, - artist => { - artistid => 0, - name => '', - rank => 0, - charfield => 0, - }, - title => '', - year => 0, - genreid => 0, - single_track => 0, + cdid => 0, title => '', year => 0, genreid => 0, single_track => 0, artist => { + artistid => 0, name => '', rank => 0, charfield => 0, + }, }); my $orig_debug = $schema->storage->debug; @@ -35,25 +25,13 @@ my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next; cmp_deeply { $cd->get_columns }, - { - artist => 0, - cdid => 0, - genreid => 0, - single_track => 0, - title => '', - year => 0, - }, + { artist => 0, cdid => 0, genreid => 0, single_track => 0, title => '', year => 0 }, 'Expected CD columns present', ; cmp_deeply { $cd->artist->get_columns }, - { - artistid => 0, - charfield => 0, - name => "", - rank => 0, - }, + { artistid => 0, charfield => 0, name => "", rank => 0 }, 'Expected Artist columns present', ; diff --git a/t/prefetch/multiple_hasmany_torture.t b/t/prefetch/multiple_hasmany_torture.t index e0b73b5..75ba477 100644 --- a/t/prefetch/multiple_hasmany_torture.t +++ b/t/prefetch/multiple_hasmany_torture.t @@ -10,280 +10,121 @@ use DBICTest; my $schema = DBICTest->init_schema(); my $mo_rs = $schema->resultset('Artist')->search( - { 'me.artistid' => 4 }, - { - prefetch => [ - { - cds => [ - { tracks => { cd_single => 'tracks' } }, - { cd_to_producer => 'producer' } - ] - }, - { artwork_to_artist => 'artwork' } - ], + { 'me.artistid' => 4 }, + { + prefetch => [ + { + cds => [ + { tracks => { cd_single => 'tracks' } }, + { cd_to_producer => 'producer' } + ] + }, + { artwork_to_artist => 'artwork' } + ], - result_class => 'DBIx::Class::ResultClass::HashRefInflator', + result_class => 'DBIx::Class::ResultClass::HashRefInflator', - order_by => [qw/tracks.position tracks.trackid producer.producerid/], - } + order_by => [qw/tracks.position tracks.trackid producer.producerid/], + } ); $schema->resultset('Artist')->create( - { - name => 'mo', - rank => '1337', - cds => [ - { - title => 'Song of a Foo', - year => '1999', - tracks => [ - { - title => 'Foo Me Baby One More Time', - }, - { - title => 'Foo Me Baby One More Time II', - }, - { - title => 'Foo Me Baby One More Time III', - }, - { - title => 'Foo Me Baby One More Time IV', - cd_single => - { artist => 1, title => 'MO! Single', year => 2021, tracks => [ - { title => 'singled out' }, { title => 'still alone' }, - ] }, - } - ], - cd_to_producer => [ - { producer => { name => 'riba' } }, - { producer => { name => 'sushi' } }, - ] - }, - { - title => 'Song of a Foo II', - year => '2002', - tracks => [ - { - title => 'Quit Playing Games With My Heart', - }, - { - title => 'Bar Foo', - }, - { - title => 'Foo Bar', - cd_single => - { artist => 2, title => 'MO! Single', year => 2020, tracks => [ - { title => 'singled out' }, { title => 'still alone' }, - ] }, - } - ], - cd_to_producer => [ - { producer => { name => 'riba' } }, - { producer => { name => 'sushi' } }, - ], - } + { + name => 'mo', + rank => '1337', + cds => [ + { + title => 'Song of a Foo', + year => '1999', + tracks => [ + { title => 'Foo Me Baby One More Time' }, + { title => 'Foo Me Baby One More Time II' }, + { title => 'Foo Me Baby One More Time III' }, + { title => 'Foo Me Baby One More Time IV', cd_single => { + artist => 1, title => 'MO! Single', year => 2021, tracks => [ + { title => 'singled out' }, + { title => 'still alone' }, + ] + } } ], - artwork_to_artist => - [ { artwork => { cd_id => 1 } }, { artwork => { cd_id => 2 } } ] - } + cd_to_producer => [ + { producer => { name => 'riba' } }, + { producer => { name => 'sushi' } }, + ] + }, + { + title => 'Song of a Foo II', + year => '2002', + tracks => [ + { title => 'Quit Playing Games With My Heart' }, + { title => 'Bar Foo' }, + { title => 'Foo Bar', cd_single => { + artist => 2, title => 'MO! Single', year => 2020, tracks => [ + { title => 'singled out' }, + { title => 'still alone' }, + ] + } } + ], + cd_to_producer => [ + { producer => { name => 'riba' } }, + { producer => { name => 'sushi' } }, + ], + } + ], + artwork_to_artist => [ + { artwork => {cd_id => 1 } }, + { artwork => { cd_id => 2 } } + ] + } ); my $mo = $mo_rs->next; is( @{$mo->{cds}}, 2, 'two CDs' ); -cmp_deeply( - $mo, +cmp_deeply( $mo, { + artistid => 4, charfield => undef, name => 'mo', rank => 1337, + artwork_to_artist => [ + { artist_id => 4, artwork_cd_id => 1, artwork => { cd_id => 1 } }, + { artist_id => 4, artwork_cd_id => 2, artwork => { cd_id => 2 } }, + ], + cds => [ { - 'cds' => [ - { - 'single_track' => undef, - 'tracks' => [ - { - 'cd' => '6', - 'position' => '1', - 'trackid' => '19', - 'title' => 'Foo Me Baby One More Time', - 'cd_single' => undef, - 'last_updated_on' => undef, - 'last_updated_at' => undef - }, - { - 'cd' => '6', - 'position' => '2', - 'trackid' => '20', - 'title' => 'Foo Me Baby One More Time II', - 'cd_single' => undef, - 'last_updated_on' => undef, - 'last_updated_at' => undef - }, - { - 'cd' => '6', - 'position' => '3', - 'trackid' => '21', - 'title' => 'Foo Me Baby One More Time III', - 'cd_single' => undef, - 'last_updated_on' => undef, - 'last_updated_at' => undef - }, - { - 'cd' => '6', - 'position' => '4', - 'trackid' => '22', - 'title' => 'Foo Me Baby One More Time IV', - 'last_updated_on' => undef, - 'last_updated_at' => undef, - 'cd_single' => { - 'single_track' => '22', - 'artist' => '1', - 'cdid' => '7', - 'title' => 'MO! Single', - 'genreid' => undef, - 'year' => '2021', - 'tracks' => [ - { - 'cd' => '7', - 'position' => '1', - 'title' => 'singled out', - 'trackid' => '23', - 'last_updated_at' => undef, - 'last_updated_on' => undef - }, - { - 'cd' => '7', - 'position' => '2', - 'title' => 'still alone', - 'trackid' => '24', - 'last_updated_at' => undef, - 'last_updated_on' => undef - }, - ], - }, - } - ], - 'artist' => '4', - 'cdid' => '6', - 'cd_to_producer' => [ - { - 'attribute' => undef, - 'cd' => '6', - 'producer' => { - 'name' => 'riba', - 'producerid' => '4' - } - }, - { - 'attribute' => undef, - 'cd' => '6', - 'producer' => { - 'name' => 'sushi', - 'producerid' => '5' - } - } - ], - 'title' => 'Song of a Foo', - 'genreid' => undef, - 'year' => '1999' - }, - { - 'single_track' => undef, - 'tracks' => [ - { - 'cd' => '8', - 'position' => '1', - 'trackid' => '25', - 'title' => 'Quit Playing Games With My Heart', - 'last_updated_on' => undef, - 'last_updated_at' => undef, - 'cd_single' => undef, - }, - { - 'cd' => '8', - 'position' => '2', - 'trackid' => '26', - 'title' => 'Bar Foo', - 'cd_single' => undef, - 'last_updated_on' => undef, - 'last_updated_at' => undef - }, - { - 'cd' => '8', - 'position' => '3', - 'trackid' => '27', - 'title' => 'Foo Bar', - 'last_updated_on' => undef, - 'last_updated_at' => undef, - 'cd_single' => { - 'single_track' => '27', - 'artist' => '2', - 'cdid' => '9', - 'title' => 'MO! Single', - 'genreid' => undef, - 'year' => '2020', - 'tracks' => [ - { - 'cd' => '9', - 'position' => '1', - 'title' => 'singled out', - 'trackid' => '28', - 'last_updated_at' => undef, - 'last_updated_on' => undef - }, - { - 'cd' => '9', - 'position' => '2', - 'title' => 'still alone', - 'trackid' => '29', - 'last_updated_at' => undef, - 'last_updated_on' => undef - }, - ], - - }, - }, - ], - 'artist' => '4', - 'cdid' => '8', - 'cd_to_producer' => [ - { - 'attribute' => undef, - 'cd' => '8', - 'producer' => { - 'name' => 'riba', - 'producerid' => '4' - } - }, - { - 'attribute' => undef, - 'cd' => '8', - 'producer' => { - 'name' => 'sushi', - 'producerid' => '5' - } - } - ], - 'title' => 'Song of a Foo II', - 'genreid' => undef, - 'year' => '2002' - } - ], - 'artistid' => '4', - 'charfield' => undef, - 'name' => 'mo', - 'artwork_to_artist' => [ - { - 'artwork' => { 'cd_id' => '1' }, - 'artist_id' => '4', - 'artwork_cd_id' => '1' - }, - { - 'artwork' => { 'cd_id' => '2' }, - 'artist_id' => '4', - 'artwork_cd_id' => '2' - } - ], - 'rank' => '1337' + artist => 4, cdid => 6, title => 'Song of a Foo', genreid => undef, year => 1999, single_track => undef, + cd_to_producer => [ + { attribute => undef, cd => 6, producer => { name => 'riba', producerid => 4 } }, + { attribute => undef, cd => 6, producer => { name => 'sushi', producerid => 5 } }, + ], + tracks => [ + { cd => 6, position => 1, trackid => 19, title => 'Foo Me Baby One More Time', last_updated_on => undef, last_updated_at => undef, cd_single => undef }, + { cd => 6, position => 2, trackid => 20, title => 'Foo Me Baby One More Time II', last_updated_on => undef, last_updated_at => undef, cd_single => undef }, + { cd => 6, position => 3, trackid => 21, title => 'Foo Me Baby One More Time III', last_updated_on => undef, last_updated_at => undef, cd_single => undef }, + { cd => 6, position => 4, trackid => 22, title => 'Foo Me Baby One More Time IV', last_updated_on => undef, last_updated_at => undef, cd_single => { + single_track => 22, artist => 1, cdid => 7, title => 'MO! Single', genreid => undef, year => 2021, tracks => [ + { cd => 7, position => 1, title => 'singled out', trackid => '23', last_updated_at => undef, last_updated_on => undef }, + { cd => 7, position => 2, title => 'still alone', trackid => '24', last_updated_at => undef, last_updated_on => undef }, + ], + } } + ], + }, + { + artist => 4, cdid => 8, title => 'Song of a Foo II', genreid => undef, year => 2002, single_track => undef, + cd_to_producer => [ + { attribute => undef, cd => 8, producer => { name => 'riba', producerid => 4 } }, + { attribute => undef, cd => 8, producer => { name => 'sushi', producerid => 5 } }, + ], + tracks => [ + { cd => 8, position => 1, trackid => 25, title => 'Quit Playing Games With My Heart', last_updated_on => undef, last_updated_at => undef, cd_single => undef }, + { cd => 8, position => 2, trackid => 26, title => 'Bar Foo', last_updated_on => undef, last_updated_at => undef, cd_single => undef }, + { cd => 8, position => 3, trackid => 27, title => 'Foo Bar', last_updated_on => undef, last_updated_at => undef, cd_single => { + single_track => 27, artist => 2, cdid => 9, title => 'MO! Single', genreid => undef, year => 2020, tracks => [ + { cd => 9, position => 1, title => 'singled out', trackid => '28', last_updated_at => undef, last_updated_on => undef }, + { cd => 9, position => 2, title => 'still alone', trackid => '29', last_updated_at => undef, last_updated_on => undef }, + ], + } } + ], } -); + ], +}); done_testing;