#!/usr/bin/perl
+
use strict;
use warnings;
use Test::More;
use File::Spec;
use File::Copy;
-use Time::HiRes qw/time sleep/;
#warn "$dsn $user $pass";
my ($dsn, $user, $pass);
plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
unless ($dsn);
+ eval { require Time::HiRes }
+ || plan skip_all => 'Test needs Time::HiRes';
+ Time::HiRes->import(qw/time sleep/);
- eval "use DBD::mysql; use SQL::Translator 0.09;";
- plan $@
- ? ( skip_all => 'needs DBD::mysql and SQL::Translator 0.09 for testing' )
- : ( tests => 23 );
+ require DBIx::Class::Storage::DBI;
+ plan skip_all =>
+ 'Test needs SQL::Translator ' . DBIx::Class::Storage::DBI->_sqlt_minimum_version
+ if not DBIx::Class::Storage::DBI->_sqlt_version_ok;
}
my $version_table_name = 'dbix_class_schema_versions';
};
use lib qw(t/lib);
+use DBICTest; # do not remove even though it is not used
+
use_ok('DBICVersionOrig');
my $schema_orig = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_version => 1 });
{
my $w;
local $SIG{__WARN__} = sub { $w = shift };
+
+ sleep 1; # remove this when TODO below is completed
+
$schema_upgrade->upgrade();
like ($w, qr/Attempting upgrade\.$/, 'Warn before upgrade');
}
# should overwrite files and warn about it
my @w;
- local $SIG{__WARN__} = sub { push @w, shift };
+ local $SIG{__WARN__} = sub {
+ if ($_[0] =~ /Overwriting existing/) {
+ push @w, $_[0];
+ }
+ else {
+ warn @_;
+ }
+ };
$schema_upgrade->create_ddl_dir('MySQL', '2.0', $ddl_dir, '1.0');
is (2, @w, 'A warning generated for both the DDL and the diff');
- like ($w[0], qr/^Overwriting existing DDL file - $fn->{v2}/, 'New version DDL overwrite warning');
- like ($w[1], qr/^Overwriting existing diff file - $fn->{trans}/, 'Upgrade diff overwrite warning');
+ like ($w[0], qr/Overwriting existing DDL file - $fn->{v2}/, 'New version DDL overwrite warning');
+ like ($w[1], qr/Overwriting existing diff file - $fn->{trans}/, 'Upgrade diff overwrite warning');
}
{
}
# attempt a deploy/upgrade cycle within one second
-{
+TODO: {
+
+ local $TODO = 'To fix this properly the table must be extended with an autoinc column, mst will not accept anything less';
+
eval { $schema_orig->storage->dbh->do('drop table ' . $version_table_name) };
eval { $schema_orig->storage->dbh->do('drop table ' . $old_table_name) };
eval { $schema_orig->storage->dbh->do('drop table TestVersion') };
$schema_orig->deploy;
}
- my $w;
- local $SIG{__WARN__} = sub { $w = shift };
+ local $SIG{__WARN__} = sub { warn if $_[0] !~ /Attempting upgrade\.$/ };
$schema_upgrade->upgrade();
- like ($w, qr/Attempting upgrade\.$/, 'Warn before upgrade');
is($schema_upgrade->get_db_version(), '2.0', 'Fast deploy/upgrade');
-}
+};
unless ($ENV{DBICTEST_KEEP_VERSIONING_DDL}) {
unlink $_ for (values %$fn);
}
+
+done_testing;