use lib qw(t/lib);
use ExtraTest::Schema;
+use Test::TempDir::Tiny;
+use IO::All;
+
+my $tempdir = tempdir;
(my $schema = ExtraTest::Schema->connect(
'DBI:SQLite::memory:','',''))->init_schema;
-open(my $fh, '<', 't/18-extra.t') ||
+open(my $fh, '<', io->catfile(qw't 18-extra.t')->name) ||
die "Can't open the filehandle, test is trash!";
ok my $row = $schema
->resultset('Photo')
->create({
- photographer=>'john',
+ album=> {name=>'masterpiece'},
+ photographer=> {name=>'john'},
file=>$fh,
});
my $fixtures = DBIx::Class::Fixtures
->new({
- config_dir => 't/var/configs',
- config_attrs => { photo_dir => './t/var/files' },
+ config_dir => io->catfile(qw't var configs')->name,
+ config_attrs => { photo_dir => io->catfile(qw't var files')->name },
debug => 0 });
ok(
$fixtures->dump({
config => 'extra.json',
schema => $schema,
- directory => "t/var/fixtures/photos" }),
+ directory => io->catfile($tempdir, qw" photos")->name }),
'fetch dump executed okay');
ok my $key = $schema->resultset('Photo')->first->file;
ok -e $key, 'File Created';
ok $schema->resultset('Photo')->delete;
+ok $schema->resultset('Photographer')->delete;
+ok $schema->resultset('Album')->delete;
ok ! -e $key, 'File Deleted';
$fixtures->populate({
no_deploy => 1,
schema => $schema,
- directory => "t/var/fixtures/photos"}),
+ directory => io->catfile($tempdir, qw" photos")->name}),
'populated');
is $key, $schema->resultset('Photo')->first->file,
done_testing;
END {
- rmtree 't/var/files';
- rmtree 't/var/fixtures/photos';
+ rmtree io->catfile(qw't var files')->name;
+ rmtree io->catfile($tempdir, qw'photos')->name;
}