switch tests to Test::TempDir::Tiny to enable parallelization
[dbsrgits/DBIx-Class-Fixtures.git] / t / 03-dump-quantity.t
CommitLineData
5eab44a9 1#!perl
2
3use DBIx::Class::Fixtures;
4use Test::More tests => 10;
5use lib qw(t/lib);
6use DBICTest;
7use Path::Class;
8use Data::Dumper;
01a3246a 9use Test::TempDir::Tiny;
66d02e24 10use IO::All;
01a3246a 11
12my $tempdir = tempdir;
5eab44a9 13# set up and populate schema
01a3246a 14ok(my $schema = DBICTest->init_schema(db_dir => $tempdir), 'got schema');
5eab44a9 15
66d02e24 16my $config_dir = io->catfile(qw't var configs')->name;
5eab44a9 17
18# do dump
19ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir');
01a3246a 20ok($fixtures->dump({ config => 'quantity.json', schema => $schema, directory => $tempdir }), 'quantity dump executed okay');
5eab44a9 21
22# check dump is okay
01a3246a 23my $dir = dir(io->catfile($tempdir, qw'CD')->name);
5eab44a9 24my @children = $dir->children;
25is(scalar(@children), 3, 'right number of cd fixtures created');
26
27foreach my $cd_fix_file (@children) {
28 my $HASH1; eval($cd_fix_file->slurp());
29 is(ref $HASH1, 'HASH', 'fixture evals into hash');
30 my $cd = $schema->resultset('CD')->find($HASH1->{cdid});
31 is_deeply({$cd->get_columns}, $HASH1, 'dumped fixture is equivalent to cd row');
32}