Commit | Line | Data |
385c593b |
1 | use strict; |
2 | use lib qw(t/lib); |
3 | use Test::More; |
4 | use DBI; |
5 | |
6 | my $DUMP_DIR; |
7 | BEGIN { |
8 | $DUMP_DIR = './t/_common_dump'; |
9 | } |
10 | |
11 | use lib $DUMP_DIR; |
12 | use DBIx::Class::Schema::Loader 'make_schema_at', "dump_to_dir:$DUMP_DIR"; |
13 | use File::Path; |
14 | |
15 | my $dsn = $ENV{DBICTEST_MSSQL_ODBC_DSN} || ''; |
16 | my $user = $ENV{DBICTEST_MSSQL_ODBC_USER} || ''; |
17 | my $password = $ENV{DBICTEST_MSSQL_ODBC_PASS} || ''; |
18 | |
19 | if( !$dsn || !$user ) { |
20 | plan skip_all => 'You need to set the DBICTEST_MSSQL_ODBC_DSN, _USER, and _PASS environment variables'; |
21 | exit; |
22 | } |
23 | |
24 | plan tests => 3; |
25 | |
26 | my $dbh = DBI->connect($dsn, $user, $password, { |
27 | RaiseError => 1, PrintError => 0 |
28 | }); |
29 | |
ec5632bc |
30 | eval { $dbh->do('DROP TABLE [loadertest.dot]') }; |
385c593b |
31 | $dbh->do(q{ |
ec5632bc |
32 | CREATE TABLE [loadertest.dot] ( |
385c593b |
33 | id INT IDENTITY NOT NULL PRIMARY KEY, |
34 | dat VARCHAR(8) |
35 | ) |
36 | }); |
37 | |
38 | rmtree $DUMP_DIR; |
39 | |
40 | eval { |
41 | make_schema_at( |
42 | 'TestSL::Schema', |
ec5632bc |
43 | { |
44 | use_namespaces => 1, |
45 | constraint => qr/^loadertest\.dot\z/ |
46 | }, |
6ed0a90c |
47 | [ $dsn, $user, $password, ] |
385c593b |
48 | ); |
49 | }; |
50 | |
51 | ok !$@, 'table name with . parsed correctly'; |
52 | diag $@ if $@; |
53 | |
ec5632bc |
54 | #system qq{$^X -pi -e 's/"test\.dot"/\\\\"[loadertest.dot]"/' t/_common_dump/TestSL/Schema/Result/TestDot.pm}; |
385c593b |
55 | #diag do { local ($/, @ARGV) = (undef, "t/_common_dump/TestSL/Schema/Result/TestDot.pm"); <> }; |
ff30991a |
56 | #do "t/_common_dump/TestSL/Schema/Result/TestDot.pm"; |
6ed0a90c |
57 | |
58 | eval 'use TestSL::Schema'; |
59 | ok !$@, 'loaded schema'; |
385c593b |
60 | diag $@ if $@; |
61 | |
6ed0a90c |
62 | TODO: { |
63 | local $TODO = q{this is really a DBIC test to check if the table is usable, |
64 | and it doesn't work in the released version yet}; |
65 | |
66 | eval { |
ec5632bc |
67 | my $rs = TestSL::Schema->resultset('LoadertestDot'); |
6ed0a90c |
68 | my $row = $rs->create({ dat => 'foo' }); |
69 | $row->update({ dat => 'bar' }); |
70 | $row = $rs->find($row->id); |
71 | $row->delete; |
72 | }; |
73 | ok !$@, 'used table from DBIC succeessfully'; |
74 | diag $@ if $@; |
75 | } |
76 | |
ff30991a |
77 | rmtree $DUMP_DIR; |
385c593b |
78 | |
ec5632bc |
79 | $dbh->do('DROP TABLE [loadertest.dot]'); |