From: Dagfinn Ilmari Mannsåker Date: Thu, 18 Feb 2016 19:47:29 +0000 (+0000) Subject: Use common infrastructure to create/drop extra Firebird objects X-Git-Tag: 0.07046~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f7c4e9aebeb9279e7540638c1a367d8c186582c2;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Use common infrastructure to create/drop extra Firebird objects For this to work if the different Firebird DSNs point to the same database we need to explicitly disconnect between each connect_info set when only running extra tests. Running all the tests already does this. --- diff --git a/t/10_09firebird_common.t b/t/10_09firebird_common.t index 69611a7..47fff42 100644 --- a/t/10_09firebird_common.t +++ b/t/10_09firebird_common.t @@ -121,38 +121,41 @@ my $tester = dbixcsl_common_tests->new( }, extra => { count => 9, + create => [ + q{ + CREATE TABLE "Firebird_Loader_Test1" ( + "Id" INTEGER NOT NULL PRIMARY KEY, + "Foo" INTEGER DEFAULT 42 + ) + }, + q{ + CREATE GENERATOR "Gen_Firebird_Loader_Test1_Id" + }, + q{ + CREATE TRIGGER "Firebird_Loader_Test1_BI" for "Firebird_Loader_Test1" + ACTIVE BEFORE INSERT POSITION 0 + AS + BEGIN + IF (NEW."Id" IS NULL) THEN + NEW."Id" = GEN_ID("Gen_Firebird_Loader_Test1_Id",1); + END + }, + ], + pre_drop_ddl => [ + 'DROP TRIGGER "Firebird_Loader_Test1_BI"', + 'DROP GENERATOR "Gen_Firebird_Loader_Test1_Id"', + 'DROP TABLE "Firebird_Loader_Test1"', + ], run => sub { $schema = shift; my ($monikers, $classes, $self) = @_; - cleanup_extra(); - my $dbh = $schema->storage->dbh; # create a mixed case table $dbh->do($_) for ( -q{ - CREATE TABLE "Firebird_Loader_Test1" ( - "Id" INTEGER NOT NULL PRIMARY KEY, - "Foo" INTEGER DEFAULT 42 - ) -}, -q{ - CREATE GENERATOR "Gen_Firebird_Loader_Test1_Id" -}, -q{ - CREATE TRIGGER "Firebird_Loader_Test1_BI" for "Firebird_Loader_Test1" - ACTIVE BEFORE INSERT POSITION 0 - AS - BEGIN - IF (NEW."Id" IS NULL) THEN - NEW."Id" = GEN_ID("Gen_Firebird_Loader_Test1_Id",1); - END -}, ); - my $guard = Scope::Guard->new(\&cleanup_extra); - local $schema->loader->{preserve_case} = 1; $schema->loader->_setup; @@ -207,16 +210,4 @@ q{ $tester->run_tests(); } -sub cleanup_extra { - $schema->storage->disconnect; - my $dbh = $schema->storage->dbh; - - foreach my $stmt ( - 'DROP TRIGGER "Firebird_Loader_Test1_BI"', - 'DROP GENERATOR "Gen_Firebird_Loader_Test1_Id"', - 'DROP TABLE "Firebird_Loader_Test1"', - ) { - eval { $dbh->do($stmt) }; - } -} # vim:et sts=4 sw=4 tw=0: diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 7f8eb14..e49e411 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -168,6 +168,7 @@ sub run_only_extra_tests { } } + $dbh->disconnect; $self->{_created} = 1; my $file_count = grep $_ =~ SOURCE_DDL, @{ $self->{extra}{create} || [] }; @@ -188,6 +189,7 @@ sub run_only_extra_tests { $self->drop_extra_tables_only; rmtree DUMP_DIR; } + $conn->storage->disconnect; } }