Commit | Line | Data |
06b7a1cc |
1 | #!perl |
2 | |
3 | use DBIx::Class::Fixtures; |
4 | use Test::More tests => 11; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | use Path::Class; |
8 | use Data::Dumper; |
9 | |
10 | # set up and populate schema |
11 | ok(my $schema = DBICTest->init_schema(), 'got schema'); |
12 | |
13 | my $config_dir = 't/var/configs'; |
14 | |
15 | # do dump |
16 | ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir'); |
17 | ok($fixtures->dump({ config => 'rules2.json', schema => $schema, directory => 't/var/fixtures' }), 'quantity dump executed okay'); |
18 | |
19 | # check dump is okay |
20 | foreach my $test ( |
21 | [ 'artist', 1, 'Artist', 'artistid' ], |
22 | [ 'cd', 2, 'CD', 'cdid' ], |
23 | ) { |
24 | my ($dirname, $count, $moniker, $id) = @$test; |
25 | my $dir = dir("t/var/fixtures/$dirname"); |
26 | my @children = $dir->children; |
27 | is(scalar(@children), $count, "right number of $dirname fixtures created"); |
28 | |
29 | foreach my $fix_file (@children) { |
30 | my $HASH1; eval($fix_file->slurp()); |
31 | is(ref $HASH1, 'HASH', 'fixture evals into hash'); |
32 | my $obj = $schema->resultset($moniker)->find($HASH1->{$id}); |
33 | is_deeply({$obj->get_columns}, $HASH1, "dumped fixture is equivalent to $dirname row"); |
34 | } |
35 | } |
36 | |