Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package MySQL::Util::Test::DropFks; | ||
|
||
use Modern::Perl; | ||
use Carp; | ||
use Data::Dumper; | ||
use Test::More; | ||
use MySQL::Util; | ||
use Smart::Args; | ||
use lib '.', './t'; | ||
use MySQL::Util::Test::Common qw( | ||
load_db | ||
get_mysql_util | ||
); | ||
|
||
sub run { | ||
my $self = shift; | ||
$self->no_table; | ||
$self->with_table; | ||
} | ||
|
||
sub with_table { | ||
my $self = shift; | ||
my $util = $self->{util}; | ||
|
||
my $aref = $util->drop_fks('depth_2a'); | ||
ok( ref $aref eq 'ARRAY'); | ||
ok( scalar @$aref == 2); | ||
|
||
my $href = $util->get_fk_constraints('depth_2a'); | ||
ok( ( scalar keys %$href ) == 0); | ||
$href = $util->get_fk_constraints; | ||
ok( ( scalar keys %$href ) == 5); | ||
|
||
ok( $util->apply_ddl($aref) ); | ||
|
||
$href = $util->get_fk_constraints('depth_2a'); | ||
ok( ( scalar keys %$href ) == 2); | ||
$href = $util->get_fk_constraints; | ||
ok( ( scalar keys %$href ) == 7); | ||
} | ||
|
||
sub no_table { | ||
my $self = shift; | ||
my $util = $self->{util}; | ||
|
||
my $aref = $util->drop_fks; | ||
ok( ref $aref eq 'ARRAY'); | ||
ok( scalar @$aref == 7); | ||
|
||
my $href = $util->get_fk_constraints; | ||
ok( ( scalar keys %$href ) == 0); | ||
|
||
ok( $util->apply_ddl($aref) ); | ||
|
||
$href = $util->get_fk_constraints; | ||
ok( ( scalar keys %$href ) == 7); | ||
} | ||
|
||
sub new { | ||
args | ||
|
||
# required | ||
my $class => 'Str', | ||
|
||
# optional | ||
my $util => { optional => 1, isa => 'MySQL::Util' }, | ||
my $load_db => { optional => 1, isa => 'Bool', default => 1 }; | ||
|
||
my $self = {}; | ||
|
||
if ($load_db) { | ||
load_db(); | ||
} | ||
|
||
$self->{util} = $util ? $util : get_mysql_util(); | ||
|
||
return bless $self, $class; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters