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