From: Brandon Black Date: Tue, 11 Jul 2006 04:30:19 +0000 (+0000) Subject: slight improvement to dump tests X-Git-Tag: 0.03004~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3e3c3fc76dac9388e1b34f82c8ad46645af4eb1a;p=dbsrgits%2FDBIx-Class-Schema-Loader.git slight improvement to dump tests --- diff --git a/t/22dump.t b/t/22dump.t index 5f6ff6a..54193d9 100644 --- a/t/22dump.t +++ b/t/22dump.t @@ -1,21 +1,49 @@ use strict; use Test::More; use lib qw(t/lib); +use File::Path; use make_dbictest_db; +my $dump_path = './t/_dump'; + +{ + package DBICTest::Schema::1; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( + relationships => 1, + dump_directory => $dump_path, + ); +} + { - package DBICTest::Schema; + package DBICTest::Schema::2; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->loader_options( relationships => 1, - dump_directory => './t/_dump', + dump_directory => $dump_path, dump_overwrite => 1, ); - } -plan tests => 1; +plan tests => 4; + +rmtree($dump_path, 1, 0711); + +eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; +ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@"; + +DBICTest::Schema::1->loader(undef); +eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; +like($@, qr|DBICTest/Schema/1.pm exists, will not overwrite|, + 'death when attempting to overwrite without option'); + +rmtree($dump_path, 1, 0711); + +eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; +ok(!$@, 'no death with dump_directory set (overwrite1)') or diag "Dump failed: $@"; + +DBICTest::Schema::2->loader(undef); +eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; +ok(!$@, 'no death with dump_directory set (overwrite2)') or diag "Dump failed: $@"; -eval { DBICTest::Schema->connect($make_dbictest_db::dsn) }; -ok(!$@, 'no death with dump_directory set') - or diag "Dump failed: $@"; +END { rmtree($dump_path, 1, 0711); }