X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F86sqlt.t;h=3430cec8c3abe339ed601b61bea03f506cfca332;hb=4549ba4966c026a49409c7dde70f32b2512250b0;hp=26e1fc27b4a0093dcc2f97d026e8c0f74636bbaa;hpb=827a808f2651b5460a8a8f9ae8bfeed0e062b302;p=dbsrgits%2FDBIx-Class.git diff --git a/t/86sqlt.t b/t/86sqlt.t index 26e1fc2..3430cec 100644 --- a/t/86sqlt.t +++ b/t/86sqlt.t @@ -6,10 +6,18 @@ use lib qw(t/lib); use DBICTest; BEGIN { - require DBIx::Class::Storage::DBI; + require DBIx::Class; plan skip_all => - 'Test needs SQL::Translator ' . DBIx::Class::Storage::DBI->_sqlt_minimum_version - if not DBIx::Class::Storage::DBI->_sqlt_version_ok; + 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') +} + +my $custom_deployment_statements_called = 0; + +sub DBICTest::Schema::deployment_statements { + $custom_deployment_statements_called = 1; + my $self = shift; + return $self->next::method(@_); } my $schema = DBICTest->init_schema (no_deploy => 1); @@ -44,26 +52,33 @@ my $schema = DBICTest->init_schema (no_deploy => 1); -# replace the sqlt calback with a custom version ading an index -$schema->source('Track')->sqlt_deploy_callback(sub { - my ($self, $sqlt_table) = @_; +{ + my $deploy_hook_called = 0; - is ( - $sqlt_table->schema->translator->producer_type, - join ('::', 'SQL::Translator::Producer', $schema->storage->sqlt_type), - 'Production type passed to translator object', - ); + # replace the sqlt calback with a custom version ading an index + $schema->source('Track')->sqlt_deploy_callback(sub { + my ($self, $sqlt_table) = @_; - if ($schema->storage->sqlt_type eq 'SQLite' ) { - $sqlt_table->add_index( name => 'track_title', fields => ['title'] ) - or die $sqlt_table->error; - } + $deploy_hook_called = 1; - $self->default_sqlt_deploy_hook($sqlt_table); -}); + is ( + $sqlt_table->schema->translator->producer_type, + join ('::', 'SQL::Translator::Producer', $schema->storage->sqlt_type), + 'Production type passed to translator object', + ); -$schema->deploy; # do not remove, this fires the is() test in the callback above + if ($schema->storage->sqlt_type eq 'SQLite' ) { + $sqlt_table->add_index( name => 'track_title', fields => ['title'] ) + or die $sqlt_table->error; + } + $self->default_sqlt_deploy_hook($sqlt_table); + }); + + $schema->deploy; # do not remove, this fires the is() test in the callback above + ok($deploy_hook_called, 'deploy hook got called'); + ok($custom_deployment_statements_called, '->deploy used the schemas deploy_statements method'); +} my $translator = SQL::Translator->new(