Added failing tests for `external`, fix for tests
[dbsrgits/DBIx-Class-Fixtures.git] / t / 18-extra.t
index 2bbb0e1..7af4518 100644 (file)
@@ -4,17 +4,22 @@ use File::Path 'rmtree';
 
 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,
   });
 
@@ -22,15 +27,15 @@ close($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;
@@ -38,6 +43,8 @@ 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';
 
@@ -45,7 +52,7 @@ ok(
   $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,
@@ -56,6 +63,6 @@ ok -e $key, 'File Restored';
 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;
 }