From: John Napiorkowski Date: Sun, 20 Feb 2011 22:51:36 +0000 (-0500) Subject: test for excludes option X-Git-Tag: 1.001011~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20db905fc1919c598ad094bea810885a1a67e79a;p=dbsrgits%2FDBIx-Class-Fixtures.git test for excludes option --- diff --git a/t/07-dump-all.t b/t/07-dump-all.t index 18c8bc0..57b73d7 100644 --- a/t/07-dump-all.t +++ b/t/07-dump-all.t @@ -7,7 +7,7 @@ use DBICTest; use Path::Class; use Data::Dumper; -plan tests => 9; +plan tests => 16; # set up and populate schema ok(my $schema = DBICTest->init_schema( ), 'got schema'); @@ -16,13 +16,28 @@ my $config_dir = 't/var/configs'; my $fixture_dir = 't/var/fixtures'; # do dump -ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir'); -ok($fixtures->dump({ all => 1, schema => $schema, directory => 't/var/fixtures' }), 'fetch dump executed okay'); +{ + ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir'); + ok($fixtures->dump({ all => 1, schema => $schema, directory => $fixture_dir }), 'fetch dump executed okay'); + foreach my $source ($schema->sources) { + my $rs = $schema->resultset($source); + my $dir = dir($fixture_dir, $rs->result_source->from); + my @children = $dir->children; + is (scalar(@children), $rs->count, 'all objects from $source dumped'); + } +} + +# do dump with excludes +{ + ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir'); + ok($fixtures->dump({ all => 1, schema => $schema, excludes => ['Tag'], directory => "$fixture_dir/excludes" }), 'fetch dump executed okay'); -foreach my $source ($schema->sources) { - my $rs = $schema->resultset($source); - my $dir = dir($fixture_dir, $rs->result_source->from); - my @children = $dir->children; - is (scalar(@children), $rs->count, 'all objects from $source dumped'); + foreach my $source ($schema->sources) { + my $rs = $schema->resultset($source); + next if $rs->result_source->from eq 'tags'; + my $dir = dir("$fixture_dir/excludes", $rs->result_source->from); + my @children = $dir->children; + is (scalar(@children), $rs->count, 'all objects from $source dumped'); + } }