From: Amiri Barksdale Date: Tue, 1 Jun 2010 22:19:53 +0000 (+0000) Subject: Rewrite 105view_deps.t and a ViewDeps::Result class. X-Git-Tag: v0.08124~114^2~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2446dc59917c62b0828e364c933ce5596255d68f;p=dbsrgits%2FDBIx-Class.git Rewrite 105view_deps.t and a ViewDeps::Result class. --- diff --git a/t/105view_deps.t b/t/105view_deps.t index 4900bf6..796f3da 100644 --- a/t/105view_deps.t +++ b/t/105view_deps.t @@ -9,8 +9,10 @@ use lib qw(t/lib); use ViewDeps; use Devel::Dwarn; use Data::Dumper; +use Carp::Always; BEGIN { + $ENV{DBIC_TRACE} = 1; use_ok('DBIx::Class::ResultSource::View'); } @@ -24,8 +26,16 @@ isa_ok( $view, 'DBIx::Class', 'A new view also' ); can_ok( $view, $_ ) for qw/new from deploy_depends_on/; ### DEPS +#if (-e "t/var/viewdeps.db") { +#ok(unlink("t/var/viewdeps.db"),"Deleted old DB OK"); +#} +my @sql_files = glob("t/sql/ViewDeps*.sql"); +for (@sql_files) { + ok( unlink($_), "Deleted old SQL $_ OK" ); +} -my $schema = ViewDeps->connect; +my $schema = ViewDeps->connect( 'dbi:SQLite:dbname=t/var/viewdeps.db', + { quote_char => '"', } ); ok( $schema, 'Connected to ViewDeps schema OK' ); my $deps_ref = { @@ -41,33 +51,29 @@ my $deps_ref = { diag( Dwarn $deps_ref); +my @sorted_sources = sort { + keys %{ $deps_ref->{$a} || {} } <=> keys %{ $deps_ref->{$b} || {} } + || $a cmp $b + } + keys %$deps_ref; -#isa_ok( $schema->resultset('Bar')->result_source, -#'DBIx::Class::ResultSource::View', 'Bar' ); - -#is( $bar_deps[0], 'baz', 'which is reported to depend on baz...' ); -#is( $bar_deps[1], 'mixin', 'and on mixin.' ); -#is( $foo_deps[0], undef, 'Foo has no declared dependencies...' ); - -#isa_ok( -#$schema->resultset('Foo')->result_source, -#'DBIx::Class::ResultSource::View', -#'though Foo' -#); -#isa_ok( -#$schema->resultset('Baz')->result_source, -#'DBIx::Class::ResultSource::Table', -#"Baz on the other hand" -#); -#dies_ok { -#ViewDeps::Result::Baz->result_source_instance -#->deploy_depends_on("ViewDeps::Result::Mixin"); -#} -#"...and you cannot use deploy_depends_on with that"; +diag( Dwarn @sorted_sources ); ### DEPLOY -my $dir = "t/sql"; -$schema->create_ddl_dir( [ 'PostgreSQL', 'SQLite' ], 0.1, $dir ); +my $ddl_dir = "t/sql"; +$schema->create_ddl_dir( [ 'PostgreSQL', 'MySQL', 'SQLite' ], 0.1, $ddl_dir ); + +ok( -e $_, "$_ was created successfully" ) for @sql_files; + +$schema->deploy( { add_drop_table => 1 } ); + +### DOES ORDERING WORK? + +my $tr = SQL::Translator->new( add_drop_table => 1 ); +$tr->{parser_args}->{'DBIx::Class::Schema'} = $schema; +my $sqlt = SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema ); + +diag( Dwarn $sqlt); # Nope. A 1. done_testing; diff --git a/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm b/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm index 990fea7..82313c5 100644 --- a/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm +++ b/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm @@ -8,7 +8,7 @@ use base 'ViewDeps::Result::Year2010CDs'; __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); __PACKAGE__->table('year_2010_cds_with_many_tracks'); __PACKAGE__->result_source_instance->view_definition( - "SELECT cd.id,cd.title,cd.artist,cd.year,cd.number_tracks,artwork.id FROM year_2010_cds cd,artwork artwork WHERE cd.number_tracks > 10 AND artwork.cd = cd.id" + "SELECT cd.id,cd.title,cd.artist,cd.year,cd.number_tracks,art.id FROM year_2010_cds cd,artwork art WHERE cd.number_tracks > 10 AND art.cd = cd.id" ); __PACKAGE__->result_source_instance->deploy_depends_on(