mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-24 02:01:42 +08:00
Add forked Maatkit tools in bin/ and their tests in t/.
This commit is contained in:
73
t/pt-fk-error-logger/get_fk_error.t
Normal file
73
t/pt-fk-error-logger/get_fk_error.t
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 10;
|
||||
|
||||
use MaatkitTest;
|
||||
require "$trunk/bin/pt-fk-error-logger";
|
||||
|
||||
# #############################################################################
|
||||
# Test get_fk_error().
|
||||
# #############################################################################
|
||||
sub test_get_fk_error {
|
||||
my ( $file, $expected_ts, $expected_fke_file ) = @_;
|
||||
my $contents = load_file('t/pt-fk-error-logger/'.$file);
|
||||
chomp $contents;
|
||||
my ($ts, $fke) = mk_fk_error_logger::get_fk_error($contents);
|
||||
is(
|
||||
$ts,
|
||||
$expected_ts,
|
||||
"$file timestamp"
|
||||
);
|
||||
my $expected_fke = load_file('t/pt-fk-error-logger/'.$expected_fke_file);
|
||||
chomp $expected_fke;
|
||||
is(
|
||||
$fke,
|
||||
$expected_fke,
|
||||
"$file foreign key error text"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
test_get_fk_error(
|
||||
'samples/is001.txt',
|
||||
'070913 11:06:03',
|
||||
'samples/is001-fke.txt'
|
||||
);
|
||||
|
||||
test_get_fk_error(
|
||||
'samples/is002.txt',
|
||||
'070915 15:10:24',
|
||||
'samples/is002-fke.txt'
|
||||
);
|
||||
|
||||
test_get_fk_error(
|
||||
'samples/is003.txt',
|
||||
'070915 16:15:55',
|
||||
'samples/is003-fke.txt'
|
||||
);
|
||||
|
||||
test_get_fk_error(
|
||||
'samples/is004.txt',
|
||||
'070915 16:23:09',
|
||||
'samples/is004-fke.txt'
|
||||
);
|
||||
|
||||
test_get_fk_error(
|
||||
'samples/is005.txt',
|
||||
'070915 16:31:46',
|
||||
'samples/is005-fke.txt'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
exit;
|
||||
Reference in New Issue
Block a user