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