From: Amiri Barksdale at Home Date: Mon, 12 Jul 2010 03:06:47 +0000 (-0700) Subject: Already changed source_name keys in deploy_depends_on to use the new X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f839b1cf886c1b76455358e15ad9760015e95b7;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git Already changed source_name keys in deploy_depends_on to use the new view_deps API (which requires result_class keys) from DBIC; now just refactoring tests. --- diff --git a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm index d583f30..9dceab6 100644 --- a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm +++ b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm @@ -10,7 +10,6 @@ use aliased 'DBIx::Class::ResultClass::HashRefInflator'; use String::TT qw(strip tt); use Scalar::Util qw(blessed); use namespace::autoclean; -use Devel::Dwarn; our $VERSION = 0.01; diff --git a/t/02view_def.t b/t/02view_def.t index 627de1b..35e0bd7 100644 --- a/t/02view_def.t +++ b/t/02view_def.t @@ -4,20 +4,26 @@ use lib 't/lib'; use File::Temp; use Test::More qw(no_plan); use Test::Exception; -#use Devel::Dwarn; +use Devel::Dwarn; -BEGIN { use_ok 'MTITest'; } +BEGIN { + use_ok 'MTITest'; + $ENV{DBIC_TRACE} = 1; +} dies_ok { MTITest->source('Foo')->view_definition } - "Can't generate view def without connected schema"; +"Can't generate view def without connected schema"; #my $schema = MTITest->connect('dbi:SQLite::memory:'); -my $schema = MTITest->connect('dbi:Pg:dbname=mti','postgres',''); + +my $schema = MTITest->connect( 'dbi:Pg:dbname=mti', 'postgres', '' ); +diag(DwarnS $schema); #diag("MTITest view definition: ", $schema->resultset('Bar')->result_source->view_definition); -my $dir = "t/sql"; # tempdir(CLEANUP => 0); +my $dir = "t/sql"; # tempdir(CLEANUP => 0); + +$schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ); +$schema->deploy( { add_drop_table => 1, add_drop_view => 1 } ); -$schema->create_ddl_dir([ 'PostgreSQL' ], 0.1, $dir); -$schema->deploy({add_drop_table => 1, add_drop_view => 1}); #diag DwarnS $schema->source($_)->view_definition for qw(Foo Bar); #diag DwarnS $schema->source($_) for qw(Foo Bar); diff --git a/t/03cafe.t b/t/03cafe.t index e9bf592..6293ba2 100644 --- a/t/03cafe.t +++ b/t/03cafe.t @@ -4,31 +4,44 @@ use lib 't/lib'; use Test::More; use Test::Exception; use Devel::Dwarn; -use Carp::Always; BEGIN { use_ok 'Cafe'; $ENV{DBIC_TRACE} = 1; } -my $schema = Cafe->connect('dbi:Pg:dbname=cafe','postgres',''); +my $schema = Cafe->connect( 'dbi:Pg:dbname=cafe', 'postgres', '' ); +#diag( DwarnS $schema); -my $dir = "t/sql"; # tempdir(CLEANUP => 0); -$schema->create_ddl_dir([ 'PostgreSQL' ], 0.1, $dir); -$schema->deploy({add_drop_table => 1, add_drop_view => 1}); -my $drink = $schema->resultset('Sumatra')->create({sweetness => 4, aroma => 'earthy', flavor => 'great'}); -#my $cup = $schema->resultset('Coffee'); +#diag(Dwarn $schema->source('Sumatra')); +#diag(ref($schema->source('Sumatra'))); +isa_ok($schema->source('Sumatra'), 'DBIx::Class::ResultSource::View', "My MTI class also"); -#diag(Dwarn $cup->result_source->columns); -#diag(Dwarn $schema->resultset('Sumatra')->result_source->columns); + +my $dir = "t/sql"; # tempdir(CLEANUP => 0); +$schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ); + + + + + +$schema->deploy( { add_drop_table => 1, add_drop_view => 1 } ); + +my $drink = $schema->resultset('Sumatra') + ->create( { sweetness => 4, aroma => 'earthy', flavor => 'great' } ); + +my $cup = $schema->resultset('Coffee'); + +diag(Dwarn $cup->result_source->columns); +diag(Dwarn $schema->resultset('Sumatra')->result_source->columns); #my $drink = $schema->resultset('Sumatra')->new_result({sweetness => 6, aroma => 'chocolate'}); -#ok($drink, "made new drink OK"); -#$drink->insert; -#diag(Dwarn $drink->result_source->columns); +ok($drink, "made new drink OK"); +$drink->insert; +diag(Dwarn $drink->result_source->columns); -#diag(Dwarn mro::get_linear_isa $drink); +diag(Dwarn mro::get_linear_isa $drink); -#$drink->insert_or_update; +$drink->insert_or_update; done_testing; diff --git a/t/lib/Cafe/Result/Sumatra.pm b/t/lib/Cafe/Result/Sumatra.pm index ea39a60..40a693e 100644 --- a/t/lib/Cafe/Result/Sumatra.pm +++ b/t/lib/Cafe/Result/Sumatra.pm @@ -9,12 +9,9 @@ require Cafe::Result::Sugar; __PACKAGE__->table('sumatra'); __PACKAGE__->result_source_instance->add_additional_parent( Cafe::Result::Sugar->result_source_instance ); - -__PACKAGE__->add_columns( - "aroma", { data_type => "text" } -); +__PACKAGE__->add_columns( "aroma", { data_type => "text" } ); #__PACKAGE__->has_many( 'coffees', 'Cafe::Result::Coffee', - #{ 'foreign.id' => 'self.id' } ); +#{ 'foreign.id' => 'self.id' } ); 1; diff --git a/t/sql/Cafe-0.1-PostgreSQL.sql b/t/sql/Cafe-0.1-PostgreSQL.sql index 7097fa3..a9d68b5 100644 --- a/t/sql/Cafe-0.1-PostgreSQL.sql +++ b/t/sql/Cafe-0.1-PostgreSQL.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::PostgreSQL --- Created on Tue Jun 15 07:49:49 2010 +-- Created on Sun Jul 11 20:05:37 2010 -- -- -- Table: _coffee diff --git a/t/sql/MTITest-0.1-PostgreSQL.sql b/t/sql/MTITest-0.1-PostgreSQL.sql index b541a9a..049d4bc 100644 --- a/t/sql/MTITest-0.1-PostgreSQL.sql +++ b/t/sql/MTITest-0.1-PostgreSQL.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::PostgreSQL --- Created on Mon Jun 14 20:16:23 2010 +-- Created on Sun Jul 11 20:05:31 2010 -- -- -- Table: just_a_table