Commit | Line | Data |
5eab44a9 |
1 | #!perl |
2 | |
3 | use DBIx::Class::Fixtures; |
4 | use Test::More tests => 10; |
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 => 'quantity.json', schema => $schema, directory => 't/var/fixtures' }), 'quantity dump executed okay'); |
18 | |
19 | # check dump is okay |
dcdf675f |
20 | my $dir = dir('t/var/fixtures/CD'); |
5eab44a9 |
21 | my @children = $dir->children; |
22 | is(scalar(@children), 3, 'right number of cd fixtures created'); |
23 | |
24 | foreach my $cd_fix_file (@children) { |
25 | my $HASH1; eval($cd_fix_file->slurp()); |
26 | is(ref $HASH1, 'HASH', 'fixture evals into hash'); |
27 | my $cd = $schema->resultset('CD')->find($HASH1->{cdid}); |
28 | is_deeply({$cd->get_columns}, $HASH1, 'dumped fixture is equivalent to cd row'); |
29 | } |