X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F94versioning.t;h=7de9edd28324342f84c67f110a97399fe6a659b8;hb=a28009914a3e447af53737d503b1953160d146c9;hp=81245e2c337b14c0393ebe418b41e1f1ab332c97;hpb=c9d2e0a20b79cf2c65ff86e8b400ff683b18627d;p=dbsrgits%2FDBIx-Class.git diff --git a/t/94versioning.t b/t/94versioning.t index 81245e2..7de9edd 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -2,11 +2,12 @@ use strict; use warnings; use Test::More; +use File::Spec; BEGIN { - eval "use DBD::SQLite; use SQL::Translator;"; + eval "use DBD::SQLite; use SQL::Translator 0.08;"; plan $@ - ? ( skip_all => 'needs DBD::SQLite and SQL::Translator for testing' ) + ? ( skip_all => 'needs DBD::SQLite and SQL::Translator 0.08 for testing' ) : ( tests => 6 ); } @@ -20,28 +21,53 @@ unlink($db_file . "-journal") if -e $db_file . "-journal"; mkdir("t/var") unless -d "t/var"; unlink('t/var/DBICVersion-Schema-1.0-SQLite.sql'); -my $schema = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); +my $schema_orig = DBICVersion::Schema->connect( + "dbi:SQLite:$db_file", + undef, + undef, + { AutoCommit => 1 }, +); # $schema->storage->ensure_connected(); -is($schema->ddl_filename('SQLite', 't/var', '1.0'), 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Filename creation working'); -$schema->create_ddl_dir('SQLite', undef, 't/var'); +is($schema_orig->ddl_filename('SQLite', 't/var', '1.0'), File::Spec->catfile('t', 'var', 'DBICVersion-Schema-1.0-SQLite.sql'), 'Filename creation working'); +$schema_orig->create_ddl_dir('SQLite', undef, 't/var'); ok(-f 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Created DDL file'); ## do this here or let Versioned.pm do it? # $schema->deploy(); -my $tvrs = $schema->resultset('Table'); -is($schema->exists($tvrs), 1, 'Created schema from DDL file'); +my $tvrs = $schema_orig->resultset('Table'); +is($schema_orig->_source_exists($tvrs), 1, 'Created schema from DDL file'); eval "use DBICVersionNew"; -my $schema2 = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); +my $schema_new = DBICVersion::Schema->connect( + "dbi:SQLite:$db_file", + undef, + undef, + { AutoCommit => 1 }, +); unlink('t/var/DBICVersion-Schema-2.0-SQLite.sql'); unlink('t/var/DBICVersion-Schema-1.0-2.0-SQLite.sql'); -$schema2->create_ddl_dir('SQLite', undef, 't/var', '1.0'); +$schema_new->create_ddl_dir('SQLite', undef, 't/var', '1.0'); ok(-f 't/var/DBICVersion-Schema-1.0-2.0-SQLite.sql', 'Created DDL upgrade file'); +## create new to pick up filedata for upgrade files we just made (on_connect) +my $schema_upgrade = DBICVersion::Schema->connect( + "dbi:SQLite:$db_file", + undef, + undef, + { AutoCommit => 1 }, +); + ## do this here or let Versioned.pm do it? -$schema2->upgrade(); -$tvrs = $schema2->resultset('Table'); -is($schema2->exists($tvrs), 1, 'Upgraded schema from DDL file'); +$schema_upgrade->upgrade(); +$tvrs = $schema_upgrade->resultset('Table'); +is($schema_upgrade->_source_exists($tvrs), 1, 'Upgraded schema from DDL file'); + +unlink($db_file) if -e $db_file; +unlink($db_file . "-journal") if -e $db_file . "-journal"; +unlink('t/var/DBICVersion-Schema-1.0-SQLite.sql'); +unlink('t/var/DBICVersion-Schema-2.0-SQLite.sql'); +unlink('t/var/DBICVersion-Schema-1.0-2.0-SQLite.sql'); +unlink();