Alzabo
view release on metacpan or search on metacpan
t/05b-rules-pg.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;
unless ( eval { require DBD::Pg } && ! $@ )
{
plan skip_all => 'needs DBD::Pg';
exit;
}
plan tests => 13;
my $new_schema;
eval_ok( sub { $new_schema = Alzabo::Create::Schema->new( name => 'hello_there',
rdbms => 'PostgreSQL' ) },
"Make a new PostgreSQL schema named 'hello_there'" );
{
eval { Alzabo::Create::Schema->new( name => "hello'there",
rdbms => 'PostgreSQL' ); };
my $e = $@;
isa_ok( $e, 'Alzabo::Exception::RDBMSRules',
"Exceptiont thrown from attempt to create a PostgreSQL schema named hello\'there" );
}
{
eval { $new_schema->make_table( name => 'x' x 65 ) };
my $e = $@;
isa_ok( $e, 'Alzabo::Exception::RDBMSRules',
"Exception thrown from attempt to create a table in PostgreSQL with a 65 character name" );
}
my $table = $new_schema->make_table( name => 'quux' );
{
eval { $table->make_column( name => 'foo2',
type => 'text',
length => 1,
); };
my $e = $@;
isa_ok( $e, 'Alzabo::Exception::RDBMSRules',
"Exception thrown from attempt to make 'text' column with a length parameter" );
}
{
foreach my $type ( qw( DATE TIMESTAMP TIMESTAMPTZ ) )
{
my $col = $table->make_column( name => "col_$type",
type => $type,
);
ok( $col->is_date, "$type is date" );
};
( run in 0.545 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )