test_requires 'Test::Exception' => '0.31';
test_requires 'Test::More' => '0.94';
test_requires 'Test::Warn' => '0.21';
+test_requires 'Test::Differences' => '0.60';
requires 'Carp::Clan' => 0;
requires 'Class::Accessor::Grouped' => '0.10008';
use Test::More;
use Test::Exception;
+use Test::Differences;
use DBIx::Class::Schema::Loader;
use Class::Unload;
use File::Path 'rmtree';
use DBI;
-use Digest::MD5;
use File::Find 'find';
use Class::Unload ();
use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file sigwarn_silencer/;
q{ INSERT INTO loader_test30 (id,loader_test2) VALUES(321, 2) },
);
- # get md5
- my $digest = Digest::MD5->new;
+ # get contents
+ my %contents;
my $find_cb = sub {
return if -d;
open my $fh, '<', $_ or die "Could not open $_ for reading: $!";
binmode $fh;
- $digest->addfile($fh);
+ local $/;
+ $contents{$File::Find::name} = <$fh>;
};
find $find_cb, DUMP_DIR;
+ my %contents_before = %contents;
# system "rm -rf /tmp/before_rescan /tmp/after_rescan";
# system "mkdir /tmp/before_rescan";
# system "mkdir /tmp/after_rescan";
# system "cp -a @{[DUMP_DIR]} /tmp/before_rescan";
- my $before_digest = $digest->b64digest;
-
$conn->storage->disconnect; # needed for Firebird and Informix
my $dbh = $self->dbconnect(1);
$dbh->do($_) for @statements_rescan;
# system "cp -a @{[DUMP_DIR]} /tmp/after_rescan";
- $digest = Digest::MD5->new;
+ undef %contents;
find $find_cb, DUMP_DIR;
- my $after_digest = $digest->b64digest;
-
- is $before_digest, $after_digest,
- 'dumped files are not rewritten when there is no modification';
+ my %contents_after = %contents;
+
+ subtest 'dumped files are not rewritten when there is no modification' => sub {
+ plan tests => 1 + scalar keys %contents_before;
+ is_deeply
+ [sort keys %contents_before],
+ [sort keys %contents_after],
+ 'same files dumped';
+ for my $file (sort keys %contents_before) {
+ eq_or_diff $contents_before{$file}, $contents_after{$file},
+ "$file not rewritten";
+ }
+ };
my $rsobj30 = $conn->resultset('LoaderTest30');
isa_ok($rsobj30, 'DBIx::Class::ResultSet');