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