From: Arthur Axel 'fREW' Schmidt Date: Sun, 4 Jul 2010 06:14:32 +0000 (-0500) Subject: Fix tests to be in-memory X-Git-Tag: v0.001002~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=624e3018cef977b18efce156c40440aa50d26e09;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git Fix tests to be in-memory --- diff --git a/t/02-instantiation-no-ddl.t b/t/02-instantiation-no-ddl.t index 66fcc44..1948051 100644 --- a/t/02-instantiation-no-ddl.t +++ b/t/02-instantiation-no-ddl.t @@ -11,11 +11,11 @@ use aliased 'DBIx::Class::DeploymentHandler', 'DH'; use File::Path 'remove_tree'; use Test::More; use Test::Exception; +use DBI; DBICDHTest::ready; - -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; VERSION1: { diff --git a/t/02-instantiation-wo-component.t b/t/02-instantiation-wo-component.t index bdea821..360335f 100644 --- a/t/02-instantiation-wo-component.t +++ b/t/02-instantiation-wo-component.t @@ -14,8 +14,8 @@ use Test::Exception; DBICDHTest::ready; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; VERSION1: { diff --git a/t/02-instantiation.t b/t/02-instantiation.t index 33de750..04a20f4 100644 --- a/t/02-instantiation.t +++ b/t/02-instantiation.t @@ -14,8 +14,8 @@ use Test::Exception; DBICDHTest::ready; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; VERSION1: { diff --git a/t/03-deprecated.t b/t/03-deprecated.t index 84e25f2..f89950e 100644 --- a/t/03-deprecated.t +++ b/t/03-deprecated.t @@ -13,8 +13,8 @@ use Test::Exception; DBICDHTest::ready; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; VERSION1: { diff --git a/t/04-preconnect.t b/t/04-preconnect.t index 4e3a77b..9d9cded 100644 --- a/t/04-preconnect.t +++ b/t/04-preconnect.t @@ -14,8 +14,8 @@ use Test::Exception; DBICDHTest::ready; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1, }, { on_connect_do => sub { die }}); +my $db = 'dbi:SQLite::memory:'; +my @connection = ($db, '', '', { ignore_version => 1, on_connect_do => sub { die }}); my $sql_dir = 't/sql'; VERSION1: { diff --git a/t/deploy_methods/sql_translator.t b/t/deploy_methods/sql_translator.t index 49b2c16..ef2dad7 100644 --- a/t/deploy_methods/sql_translator.t +++ b/t/deploy_methods/sql_translator.t @@ -9,8 +9,8 @@ use aliased 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator'; use File::Spec::Functions; use File::Path qw(rmtree mkpath); -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; DBICDHTest::ready; diff --git a/t/deploy_methods/sql_translator_deprecated.t b/t/deploy_methods/sql_translator_deprecated.t index 5a93821..617b31c 100644 --- a/t/deploy_methods/sql_translator_deprecated.t +++ b/t/deploy_methods/sql_translator_deprecated.t @@ -10,8 +10,8 @@ use aliased use File::Spec::Functions; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; DBICDHTest::ready; @@ -65,9 +65,9 @@ VERSION2: { $version = $s->schema_version; $dm->prepare_deploy; $dm->prepare_upgrade({ - from_version => '1.0', - to_version => $version, - version_set => ['1.0', $version] + from_version => '1.0', + to_version => $version, + version_set => ['1.0', $version] }); dies_ok { $s->resultset('Foo')->create({ diff --git a/t/deploy_methods/sql_translator_protoschema_transform.t b/t/deploy_methods/sql_translator_protoschema_transform.t index ef0e5a3..5527132 100644 --- a/t/deploy_methods/sql_translator_protoschema_transform.t +++ b/t/deploy_methods/sql_translator_protoschema_transform.t @@ -9,8 +9,8 @@ use aliased 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator'; use File::Spec::Functions; use File::Path qw(rmtree mkpath); -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; DBICDHTest::ready; diff --git a/t/lib/DBICDHTest.pm b/t/lib/DBICDHTest.pm index 7960e05..eddd418 100644 --- a/t/lib/DBICDHTest.pm +++ b/t/lib/DBICDHTest.pm @@ -8,7 +8,6 @@ use Test::More; use Test::Exception; sub ready { - unlink 'db.db' if -e 'db.db'; if (-d 't/sql') { remove_tree('t/sql'); mkdir 't/sql'; diff --git a/t/no-component-lib/DBICDHTest.pm b/t/no-component-lib/DBICDHTest.pm index 7960e05..eddd418 100644 --- a/t/no-component-lib/DBICDHTest.pm +++ b/t/no-component-lib/DBICDHTest.pm @@ -8,7 +8,6 @@ use Test::More; use Test::Exception; sub ready { - unlink 'db.db' if -e 'db.db'; if (-d 't/sql') { remove_tree('t/sql'); mkdir 't/sql'; diff --git a/t/version_storages/standard.t b/t/version_storages/standard.t index 211fde6..03dcd9d 100644 --- a/t/version_storages/standard.t +++ b/t/version_storages/standard.t @@ -11,8 +11,8 @@ use aliased 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator'; use DBICVersion_v1; use DBIx::Class::DeploymentHandler; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBI->connect('dbi:SQLite::memory:'); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; my $s = DBICVersion::Schema->connect(@connection); @@ -76,11 +76,12 @@ ok( 'adding another version works correctly' ); +my $u; { my $warning; local $SIG{__WARN__} = sub {$warning = shift}; - my $u = DBICVersion::Schema->connect($db, '', ''); - like( $warning, qr/Versions out of sync. This is 1.0, your database contains version 2.0, please call upgrade on your Schema./, 'warning when database/schema mismatch'); + $u = DBICVersion::Schema->connect(sub { $dbh }); + like( $warning, qr/Versions out of sync. This is 1\.0, your database contains version 2\.0, please call upgrade on your Schema\./, 'warning when database/schema mismatch'); } diff --git a/t/version_storages/tiny.t b/t/version_storages/tiny.t deleted file mode 100644 index 602d517..0000000 --- a/t/version_storages/tiny.t +++ /dev/null @@ -1,10 +0,0 @@ -#!perl - -use Test::More; -use Test::Exception; - -use lib 't/lib'; -use DBICDHTest; -use_ok 'DBIx::Class::DeploymentHandler::VersionStorage::Standard'; - -done_testing;