From: John Napiorkowski Date: Wed, 2 Mar 2011 15:51:17 +0000 (-0500) Subject: improved tests X-Git-Tag: 1.001012~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=281f2645274681d28afe933cddc57f3e7a164f53;p=dbsrgits%2FDBIx-Class-Fixtures.git improved tests --- diff --git a/t/17-dump_all_config_sets.t b/t/17-dump_all_config_sets.t index f150cac..96d03da 100644 --- a/t/17-dump_all_config_sets.t +++ b/t/17-dump_all_config_sets.t @@ -1,5 +1,5 @@ use DBIx::Class::Fixtures; -use Test::More tests => 17; +use Test::More tests => 9; use lib qw(t/lib); use DBICTest; @@ -12,38 +12,34 @@ ok my $schema = DBICTest->init_schema(), 'got schema'; ok my $fixtures = DBIx::Class::Fixtures->new({config_dir => $config_dir}), 'object created with correct config dir'; -ok( - $fixtures->dump_config_sets({ - configs => [qw/date.json rules.json/], - schema => $schema, - directory_template => sub { - my ($fixture, $params, $set) = @_; - File::Spec->catdir('t','var','fixtures','multi', $set); - }, - }), - 'simple dump executed okay', -); - -__END__ - - # check dump is okay - my $dir = dir('t/var/fixtures/artist'); - ok(-e 't/var/fixtures/artist', 'artist directory created'); - - my @children = $dir->children; - is(scalar(@children), 1, 'right number of fixtures created'); - - my $fix_file = $children[0]; - my $HASH1; eval($fix_file->slurp()); - is(ref $HASH1, 'HASH', 'fixture evals into hash'); - - is_deeply([sort $schema->source('Artist')->columns], [sort keys %{$HASH1}], 'fixture has correct keys'); - - my $artist = $schema->resultset('Artist')->find($HASH1->{artistid}); - is_deeply({$artist->get_columns}, $HASH1, 'dumped fixture is equivalent to artist row'); - - $schema->resultset('Artist')->delete; # so we can create the row again on the next line - ok($schema->resultset('Artist')->create($HASH1), 'new dbic row created from fixture'); -} + +my $ret = $fixtures->dump_config_sets({ + configs => [qw/date.json rules.json/], + schema => $schema, + directory_template => sub { + my ($fixture, $params, $set) = @_; + File::Spec->catdir('t','var','fixtures','multi', $set); + }, +}); + +ok -e 't/var/fixtures/multi/date.json/artist', + 'artist directory created'; + +my $dir = dir('t/var/fixtures/multi/date.json/artist'); +my @children = $dir->children; +is(scalar(@children), 1, 'right number of fixtures created'); + +my $fix_file = $children[0]; +my $HASH1; eval($fix_file->slurp()); +is(ref $HASH1, 'HASH', 'fixture evals into hash'); + +is_deeply([sort $schema->source('Artist')->columns], [sort keys %{$HASH1}], 'fixture has correct keys'); + +my $artist = $schema->resultset('Artist')->find($HASH1->{artistid}); +is_deeply({$artist->get_columns}, $HASH1, 'dumped fixture is equivalent to artist row'); + +$schema->resultset('Artist')->delete; # so we can create the row again on the next line + ok($schema->resultset('Artist')->create($HASH1), 'new dbic row created from fixture'); +