space-compress tests making them readable - no changes
[dbsrgits/DBIx-Class.git] / t / prefetch / false_colvalues.t
CommitLineData
f4e13e13 1use warnings;
2use strict;
3
4use Test::More;
52864fbd 5use Test::Deep;
f4e13e13 6
7use lib qw(t/lib);
8use DBICTest;
9
3d3e99db 10my $schema = DBICTest->init_schema( no_populate => 1 );
f4e13e13 11
12$schema->resultset('CD')->create({
3d3e99db 13 cdid => 0, title => '', year => 0, genreid => 0, single_track => 0, artist => {
14 artistid => 0, name => '', rank => 0, charfield => 0,
15 },
f4e13e13 16});
17
18my $orig_debug = $schema->storage->debug;
19
20my $queries = 0;
21$schema->storage->debugcb(sub { $queries++; });
22$schema->storage->debug(1);
23
24my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next;
25
52864fbd 26cmp_deeply
f4e13e13 27 { $cd->get_columns },
3d3e99db 28 { artist => 0, cdid => 0, genreid => 0, single_track => 0, title => '', year => 0 },
f4e13e13 29 'Expected CD columns present',
30;
31
52864fbd 32cmp_deeply
f4e13e13 33 { $cd->artist->get_columns },
3d3e99db 34 { artistid => 0, charfield => 0, name => "", rank => 0 },
f4e13e13 35 'Expected Artist columns present',
36;
37
38is $queries, 1, 'Only one query fired - prefetch worked';
39
40$schema->storage->debugcb(undef);
41$schema->storage->debug($orig_debug);
42
43done_testing;