From: Amiri Barksdale Date: Tue, 1 Jun 2010 23:05:29 +0000 (+0000) Subject: Finish sort order comparison in 105view_deps.t. X-Git-Tag: v0.08124~114^2~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7b008a2972e24c30d70d3ceeb7eb0bcfbe60b2c;p=dbsrgits%2FDBIx-Class.git Finish sort order comparison in 105view_deps.t. --- diff --git a/t/105view_deps.t b/t/105view_deps.t index 796f3da..46953f6 100644 --- a/t/105view_deps.t +++ b/t/105view_deps.t @@ -12,11 +12,11 @@ use Data::Dumper; use Carp::Always; BEGIN { - $ENV{DBIC_TRACE} = 1; + #$ENV{DBIC_TRACE} = 1; use_ok('DBIx::Class::ResultSource::View'); } -### SANITY +#################### SANITY my $view = DBIx::Class::ResultSource::View->new( { name => 'Quux' } ); @@ -25,10 +25,12 @@ isa_ok( $view, 'DBIx::Class', 'A new view also' ); can_ok( $view, $_ ) for qw/new from deploy_depends_on/; -### DEPS +#################### 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" ); @@ -40,7 +42,7 @@ ok( $schema, 'Connected to ViewDeps schema OK' ); my $deps_ref = { map { - $schema->resultset($_)->result_source->source_name => + $schema->resultset($_)->result_source->name => $schema->resultset($_)->result_source->deploy_depends_on } grep { @@ -49,7 +51,7 @@ my $deps_ref = { } @{ [ $schema->sources ] } }; -diag( Dwarn $deps_ref); +#diag( Dwarn $deps_ref); my @sorted_sources = sort { keys %{ $deps_ref->{$a} || {} } <=> keys %{ $deps_ref->{$b} || {} } @@ -57,9 +59,9 @@ my @sorted_sources = sort { } keys %$deps_ref; -diag( Dwarn @sorted_sources ); +#diag( Dwarn @sorted_sources ); -### DEPLOY +#################### DEPLOY my $ddl_dir = "t/sql"; $schema->create_ddl_dir( [ 'PostgreSQL', 'MySQL', 'SQLite' ], 0.1, $ddl_dir ); @@ -68,12 +70,22 @@ ok( -e $_, "$_ was created successfully" ) for @sql_files; $schema->deploy( { add_drop_table => 1 } ); -### DOES ORDERING WORK? +#################### DOES ORDERING WORK? + +my $tr = $schema->{sqlt}; +#diag("My TR isa: ", ref $tr); +#diag( Dwarn keys %{$tr->{views}}); +my @keys = keys %{$tr->{views}}; + + +my @sqlt_sources = +sort { + $tr->{views}->{$a}->{order} cmp $tr->{views}->{$b}->{order} +} +@keys; -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_sources); -diag( Dwarn $sqlt); # Nope. A 1. +is_deeply(\@sorted_sources,\@sqlt_sources,"SQLT view order triumphantly matchs our order."); done_testing; diff --git a/t/lib/ViewDeps.pm b/t/lib/ViewDeps.pm index aa3f588..d4b18e7 100644 --- a/t/lib/ViewDeps.pm +++ b/t/lib/ViewDeps.pm @@ -8,4 +8,9 @@ use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; +sub sqlt_deploy_hook { + my $self = shift; + $self->{sqlt} = shift; +} + 1;