MySQL-Util
view release on metacpan or search on metacpan
t/30-util-lite.t view on Meta::CPAN
#!perl
use Modern::Perl;
use String::Util ':all';
use Data::Dumper;
use Test::More;
use feature 'state';
use File::Which;
use MySQL::Util::Lite;
use Data::Printer alias => 'pdump';
use lib '.', './t';
require 'testlib.pl';
use vars qw($Lite);
########################
if ( !which('mysql') ) {
plan skip_all => 'mysql not found';
}
elsif ( !check_connection() ) {
plan skip_all => 'unable to connect to mysql';
}
else {
drop_db();
load_db();
constructor();
get_schema();
drop_db();
done_testing();
}
##################################
sub get_schema {
my $schema = $Lite->get_schema;
ok($schema);
ok( ref($schema) eq 'MySQL::Util::Lite::Schema' );
get_tables($schema);
}
sub get_tables {
my $schema = shift;
my $tables = $schema->tables;
ok(@$tables);
foreach my $t (@$tables) {
ok( ref($t) eq 'MySQL::Util::Lite::Table' );
get_foreign_keys($t);
get_parent_tables($t);
get_columns($t);
}
}
sub get_columns {
my $t = shift;
my $cols;
eval { $cols = $t->columns; };
ok(!$@);
( run in 2.132 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )