Commit | Line | Data |
6d01d9c1 |
1 | use DBIx::Class::Fixtures; |
2 | use Test::More; |
3 | use File::Path 'rmtree'; |
4 | |
5 | use lib qw(t/lib); |
6 | use ExtraTest::Schema; |
7 | |
8 | (my $schema = ExtraTest::Schema->connect( |
9 | 'DBI:SQLite::memory:','',''))->init_schema; |
10 | |
11 | open(my $fh, '<', 't/18-extra.t') || |
12 | die "Can't open the filehandle, test is trash!"; |
13 | |
14 | ok my $row = $schema |
15 | ->resultset('Photo') |
16 | ->create({ |
17 | photographer=>'john', |
18 | file=>$fh, |
19 | }); |
20 | |
21 | close($fh); |
22 | |
23 | my $fixtures = DBIx::Class::Fixtures |
24 | ->new({ |
25 | config_dir => 't/var/configs', |
c040a9b0 |
26 | config_attrs => { photo_dir => './t/var/files' }, |
6d01d9c1 |
27 | debug => 0 }); |
28 | |
29 | ok( |
30 | $fixtures->dump({ |
31 | config => 'extra.json', |
32 | schema => $schema, |
33 | directory => "t/var/fixtures/photos" }), |
34 | 'fetch dump executed okay'); |
35 | |
36 | ok my $key = $schema->resultset('Photo')->first->file; |
37 | |
38 | ok -e $key, 'File Created'; |
39 | |
40 | ok $schema->resultset('Photo')->delete; |
41 | |
42 | ok ! -e $key, 'File Deleted'; |
43 | |
44 | ok( |
45 | $fixtures->populate({ |
46 | no_deploy => 1, |
47 | schema => $schema, |
48 | directory => "t/var/fixtures/photos"}), |
49 | 'populated'); |
50 | |
51 | is $key, $schema->resultset('Photo')->first->file, |
52 | 'key is key'; |
53 | |
54 | ok -e $key, 'File Restored'; |
55 | |
56 | done_testing; |
57 | |
58 | END { |
59 | rmtree 't/var/files'; |
60 | rmtree 't/var/fixtures/photos'; |
61 | } |