replace ContributorsFromGit with Git::Contributors
[dbsrgits/DBIx-Class-Fixtures.git] / t / 17-dump_all_config_sets.t
1 use DBIx::Class::Fixtures;
2 use Test::More tests => 9;
3
4 use lib qw(t/lib);
5 use DBICTest;
6 use Path::Class;
7 use Data::Dumper; 
8 use File::Spec;
9
10 ok my $config_dir = 't/var/configs';
11 ok my $schema = DBICTest->init_schema(), 'got schema';
12 ok my $fixtures = DBIx::Class::Fixtures->new({config_dir => $config_dir}),
13   'object created with correct config dir';
14   
15
16 my $ret = $fixtures->dump_config_sets({
17   configs => [qw/date.json rules.json/],
18   schema => $schema,
19   directory_template => sub {
20       my ($fixture, $params, $set) = @_;
21       File::Spec->catdir('t','var','fixtures','multi', $set);
22   },
23 });
24
25 ok -e 't/var/fixtures/multi/date.json/artist',
26   'artist directory created';
27
28 my $dir = dir('t/var/fixtures/multi/date.json/artist');
29 my @children = $dir->children;
30 is(scalar(@children), 1, 'right number of fixtures created');
31
32 my $fix_file = $children[0];
33 my $HASH1; eval($fix_file->slurp());
34 is(ref $HASH1, 'HASH', 'fixture evals into hash');
35
36 is_deeply([sort $schema->source('Artist')->columns], [sort keys %{$HASH1}], 'fixture has correct keys');
37
38 my $artist = $schema->resultset('Artist')->find($HASH1->{artistid});
39 is_deeply({$artist->get_columns}, $HASH1, 'dumped fixture is equivalent to artist row');
40
41 $schema->resultset('Artist')->delete; # so we can create the row again on the next line
42  ok($schema->resultset('Artist')->create($HASH1), 'new dbic row created from fixture');
43
44
45