Alzabo
view release on metacpan or search on metacpan
t/02-create.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;
use Alzabo::Create;
use Alzabo::Config;
my @db;
my $tests = 0;
my $shared_tests = 150;
my $mysql_only_tests = 7;
my $pg_only_tests = 8;
if ( eval { require DBD::mysql } && ! $@ )
{
push @db, 'MySQL';
$tests += $shared_tests;
$tests += $mysql_only_tests;
}
if ( eval { require DBD::Pg } && ! $@ )
{
push @db, 'PostgreSQL';
$tests += $shared_tests;
$tests += $pg_only_tests;
}
unless ($tests)
{
plan skip_all => 'no database drivers available';
exit;
}
plan tests => $tests;
foreach my $db (@db)
{
my $s = Alzabo::Create::Schema->new( name => "foo_$db",
rdbms => $db,
);
ok( $s && ref $s,
"Create a schema object" );
ok( $s->name eq "foo_$db",
"Make sure schema name is " . $s->name );
isa_ok( $s->rules,"Alzabo::RDBMSRules::$db",
"Schema's rules object" );
isa_ok( $s->driver,"Alzabo::Driver::$db",
"Schema's driver object" );
my $dir = Alzabo::Config->schema_dir;
{
eval_ok( sub { $s->save_to_file },
( run in 1.448 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )