add File::Path to deps, move test deps to TestRequires, add strict and warnings to...
[dbsrgits/DBIx-Class-Fixtures.git] / t / 20-virtual-column.t
1 use strict;
2 use warnings;
3
4 use DBIx::Class::Fixtures;
5 use Test::More;
6 use Test::Fatal;
7 use File::Path 'rmtree';
8
9 use lib qw(t/lib/DBICTest);
10 use Schema3;
11 use Test::TempDir::Tiny;
12 use IO::All;
13
14 my $tempdir = tempdir;
15
16 (my $schema = Schema3->connect(
17   'DBI:SQLite::memory:','',''))->init_schema;
18
19 ok my $row = $schema
20   ->resultset('Person')
21   ->first;
22
23 ok $row->get_column('weight_to_height_ratio'),
24     'has virtual column';
25
26 my $fixtures = DBIx::Class::Fixtures
27   ->new({
28     config_dir => io->catfile(qw't var configs')->name,
29     debug => 0 });
30
31 ok(
32   $fixtures->dump({
33     config => 'virtual-columns.json',
34     schema => $schema,
35     directory => io->catfile($tempdir, 'people')->name }),
36   'fetch dump executed okay');
37
38 ok $schema->resultset('Person')->delete;
39
40 is exception {
41   $fixtures->populate({
42     no_deploy => 1,
43     schema => $schema,
44     directory => io->catfile($tempdir, 'people')->name
45   })
46 }, undef, 'populated';
47
48 $row = $schema->resultset('Person')->first;
49
50 BAIL_OUT("can't continue without data") unless $row;
51
52 ok $row->get_column('weight_to_height_ratio'),
53   'still has virtual column';
54
55 done_testing;
56
57 END {
58     rmtree io->catfile(qw't var files')->name;
59     rmtree io->catfile($tempdir, 'people')->name;
60 }