Alzabo
view release on metacpan or search on metacpan
t/98-schema-diff.t view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
use File::Spec;
use lib '.', File::Spec->catdir( File::Spec->curdir, 't', 'lib' );
use Alzabo::Test::Utils;
use Test::More;
my @rdbms_names = Alzabo::Test::Utils->rdbms_names;
unless (@rdbms_names)
{
plan skip_all => 'no test config provided';
exit;
}
my $tests_per_run = 11;
my $mysql_tests = 2;
my $pg_tests = 2;
my $tests = $tests_per_run * @rdbms_names;
$tests += $mysql_tests if grep { $_ eq 'mysql' } @rdbms_names;
$tests += $pg_tests if grep { $_ eq 'pg' } @rdbms_names;
plan tests => $tests;
Alzabo::Test::Utils->remove_all_schemas;
foreach my $rdbms (@rdbms_names)
{
my $s = Alzabo::Test::Utils->make_schema($rdbms);
my %connect = Alzabo::Test::Utils->connect_params_for($rdbms);
$s->table('employee')->delete_column( $s->table('employee')->column('name') );
eval_ok( sub { $s->create(%connect) },
"Create schema (via diff) with one column deleted" );
$s->table('department')->make_column( name => 'foo',
type => 'int',
nullable => 1 );
eval_ok( sub { $s->create(%connect) },
"Create schema (via diff) with one column added" );
$s->delete_table( $s->table('department') );
eval_ok( sub { $s->create(%connect) },
"Create schema (via diff) with one table deleted" );
$s->make_table( name => 'cruft' );
$s->table('cruft')->make_column( name => 'cruft_id',
type => 'int',
primary_key => 1,
);
eval_ok( sub { $s->create(%connect) },
( run in 0.541 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )