Commit | Line | Data |
aa9f3cc7 |
1 | #!perl |
2 | |
3 | use DBIx::Class::Fixtures; |
4 | use Test::More tests => 7; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | use Path::Class; |
8 | use Data::Dumper; |
9 | use DBICTest::Schema2; |
10 | |
11 | # set up and populate normal schema |
12 | ok(my $schema = DBICTest->init_schema(), 'got schema'); |
13 | my $config_dir = 't/var/configs'; |
14 | |
8a1df391 |
15 | my @different_connection_details = ( |
16 | 'dbi:SQLite:t/var/DBIxClassDifferent.db', |
17 | '', |
18 | '' |
19 | ) |
20 | ; |
21 | my $schema2 = DBICTest::Schema2->compose_namespace('DBICTest2') |
22 | ->connect(@different_connection_details); |
23 | |
24 | ok $schema2; |
25 | |
aa9f3cc7 |
26 | unlink('t/var/DBIxClassDifferent.db') if (-e 't/var/DBIxClassDifferent.db'); |
8a1df391 |
27 | |
aa9f3cc7 |
28 | DBICTest->deploy_schema($schema2, 't/lib/sqlite_different.sql'); |
8a1df391 |
29 | |
aa9f3cc7 |
30 | # do dump |
8a1df391 |
31 | ok(my $fixtures = DBIx::Class::Fixtures->new({ |
32 | config_dir => $config_dir, |
33 | debug => 0 |
34 | }), |
35 | 'object created with correct config dir'); |
36 | |
37 | ok($fixtures->dump({ |
38 | config => "simple.json", |
39 | schema => $schema, |
40 | directory => 't/var/fixtures' |
41 | }), |
42 | "simple dump executed okay"); |
43 | |
44 | ok($fixtures->populate({ |
45 | ddl => 't/lib/sqlite_different.sql', |
46 | connection_details => [@different_connection_details], |
47 | directory => 't/var/fixtures' |
48 | }), |
49 | 'mysql populate okay'); |
aa9f3cc7 |
50 | |
8a1df391 |
51 | ok($fixtures->populate({ |
52 | ddl => 't/lib/sqlite.sql', |
53 | connection_details => ['dbi:SQLite:t/var/DBIxClass.db', '', ''], |
54 | directory => 't/var/fixtures' |
55 | }), |
56 | 'sqlite populate okay'); |
aa9f3cc7 |
57 | |
8a1df391 |
58 | $schema = DBICTest->init_schema(no_deploy => 1); |
aa9f3cc7 |
59 | is($schema->resultset('Artist')->count, 1, 'artist imported to sqlite okay'); |