X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICDHTest.pm;h=22017e3b11215f10024a1f9e2e9847c84ada70a7;hb=7b3d00f984e43c319a637332579e950376637a3d;hp=08a7db2d4511632ceeb95401a7fc35f5193c2d81;hpb=fe3b6dffd232cf147c614485fcdb139b3079ff2b;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/t/lib/DBICDHTest.pm b/t/lib/DBICDHTest.pm index 08a7db2..22017e3 100644 --- a/t/lib/DBICDHTest.pm +++ b/t/lib/DBICDHTest.pm @@ -4,127 +4,10 @@ use strict; use warnings; use File::Path 'remove_tree'; -use Test::More; -use Test::Exception; +use DBI; -sub ready { - unlink 'db.db' if -e 'db.db'; - if (-d 't/sql') { - remove_tree('t/sql'); - mkdir 't/sql'; - } +sub dbh { + DBI->connect('dbi:SQLite::memory:', undef, undef, { RaiseError => 1 }) } -sub test_bundle { - my $bundle = shift; - my $db = 'dbi:SQLite:db.db'; - my @connection = ($db, '', '', { ignore_version => 1 }); - my $sql_dir = 't/sql'; - - ready; - - VERSION1: { - use_ok 'DBICVersion_v1'; - my $s = DBICVersion::Schema->connect(@connection); - ok($s, 'DBICVersion::Schema 1.0 instantiates correctly'); - my $handler = $bundle->new({ - upgrade_directory => $sql_dir, - schema => $s, - databases => 'SQLite', - sqltargs => { add_drop_table => 0 }, - }); - - ok($handler, 'DBIx::Class::DeploymentHandler w/1.0 instantiates correctly'); - - my $version = $s->schema_version(); - $handler->prepare_install(); - - dies_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - }) - } 'schema not deployed'; - $handler->install; - dies_ok { - $handler->install; - } 'cannot install twice'; - lives_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - }) - } 'schema is deployed'; - } - - VERSION2: { - use_ok 'DBICVersion_v2'; - my $s = DBICVersion::Schema->connect(@connection); - ok($s, 'DBICVersion::Schema 2.0 instantiates correctly'); - my $handler = $bundle->new({ - upgrade_directory => $sql_dir, - schema => $s, - databases => 'SQLite', - }); - - ok($handler, 'DBIx::Class::DeploymentHandler w/2.0 instantiates correctly'); - - my $version = $s->schema_version(); - $handler->prepare_install(); - $handler->prepare_upgrade('1.0', $version); - $handler->prepare_upgrade($version, '1.0'); - dies_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - baz => 'frew', - }) - } 'schema not deployed'; - dies_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - baz => 'frew', - }) - } 'schema not uppgrayyed'; - $handler->upgrade; - lives_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - baz => 'frew', - }) - } 'schema is deployed'; - } - - VERSION3: { - use_ok 'DBICVersion_v3'; - my $s = DBICVersion::Schema->connect(@connection); - ok($s, 'DBICVersion::Schema 3.0 instantiates correctly'); - my $handler = $bundle->new({ - upgrade_directory => $sql_dir, - schema => $s, - databases => 'SQLite', - }); - - ok($handler, 'DBIx::Class::DeploymentHandler w/3.0 instantiates correctly'); - - my $version = $s->schema_version(); - $handler->prepare_install; - $handler->prepare_upgrade( '1.0', $version ); - $handler->prepare_upgrade( '2.0', $version ); - dies_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - baz => 'frew', - biff => 'frew', - }) - } 'schema not deployed'; - $handler->upgrade; - lives_ok { - $s->resultset('Foo')->create({ - bar => 'frew', - baz => 'frew', - biff => 'frew', - }) - } 'schema is deployed'; - } -} - - 1;