From: Brandon Black Date: Tue, 11 Jul 2006 04:03:23 +0000 (+0000) Subject: Better test coverage X-Git-Tag: 0.03004~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fa994d3c6ada53f4610e6384fe924d4bf8163a68;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Better test coverage Carp::Clan switched to just DBIx::Class, less confusing to end-users More docs and deprecation info related changes --- diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index e6270f6..c57453e 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -29,8 +29,9 @@ # avoid OS X finder files \.DS_Store$ -# Don't ship the test db -^t/var +# Don't ship the test junk +^t/_dump +^t/dbictest.db # Don't ship the last dist we built :) \.tar\.gz$ diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 6c7c87a..b3cd945 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -4,7 +4,7 @@ use strict; use warnings; use base qw/DBIx::Class::Schema/; use base qw/Class::Data::Accessor/; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use UNIVERSAL::require; use Class::C3; use Scalar::Util qw/ weaken /; @@ -83,10 +83,13 @@ This method is *required* at this time, for backwards compatibility reasons. If you do not wish to change any options, just call it with an empty argument list during schema class initialization. -You should either specify this method before setting the connection -information for your schema, or specify these options as a part of -your connection information (see below). For now it will merely -warn if the ordering is wrong, but in the future this will cause problems. +Setting these options explicitly via this method B calling +C is deprecated and will stop working in version 0.04000. +For now the code merely warns about this condition. + +The preferred way of doing things is to either call C +before any connection is made, or embed the C in +the connection information itself as shown below. =cut @@ -102,7 +105,8 @@ sub loader_options { $self->_loader_args(\%args); if($self->storage && !$class->loader) { - warn "Do not set loader_options after specifying the connection info"; + warn "Do not set loader_options after specifying the connection info," + . " this will be unsupported in 0.04000"; $self->_invoke_loader; } @@ -155,7 +159,13 @@ sub connection { $self = $self->next::method(@_); my $class = ref $self || $self; - $self->_invoke_loader if $self->_loader_args && !$class->loader; + if($self->_loader_args && !$class->loader) { + $self->_invoke_loader + } + else { + warn "loader_options should be set before connecting the " + . "schema, see the DBIx::Class::Schema::Loader docs"; + } return $self; } @@ -169,14 +179,12 @@ See L. sub clone { my $self = shift; - croak "You failed to specify the required loader_options" - if !$self->_loader_args; - my $clone = $self->next::method(@_); - $clone->_loader_args($self->_loader_args); - $clone->_loader_args->{schema} = $clone; - weaken($clone->_loader_args->{schema}); + if($clone->_loader_args) { + $clone->_loader_args->{schema} = $clone; + weaken($clone->_loader_args->{schema}); + } $clone; } diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index a260f35..076536b 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -4,7 +4,7 @@ use strict; use warnings; use base qw/Class::Accessor::Fast/; use Class::C3; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use UNIVERSAL::require; use DBIx::Class::Schema::Loader::RelBuilder; use Data::Dump qw/ dump /; @@ -366,7 +366,7 @@ sub _dump_to_dir { my $schema_fn = $self->_get_dump_filename($schema_class); croak "$schema_fn exists, will not overwrite" if -f $schema_fn && !$self->dump_overwrite; - sysopen(my $schema_fh, '>', $schema_fn) + open(my $schema_fh, '>', $schema_fn) or croak "Cannot open $schema_fn for writing: $!"; print $schema_fh qq|package $schema_class;\n\n$tagline\n\n|; print $schema_fh qq|use strict;\nuse warnings;\n\n|; diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index eb20dcb..943c34f 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -4,7 +4,7 @@ use strict; use warnings; use base qw/DBIx::Class::Schema::Loader::Base Class::Accessor::Fast/; use Class::C3; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use UNIVERSAL::require; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm index aa6c259..e600ee2 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm @@ -3,7 +3,7 @@ package DBIx::Class::Schema::Loader::DBI::DB2; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI'; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use Class::C3; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 683a572..66b2745 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -3,7 +3,7 @@ package DBIx::Class::Schema::Loader::DBI::Pg; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI'; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use Class::C3; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index fa9a057..2471acd 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -3,7 +3,7 @@ package DBIx::Class::Schema::Loader::DBI::SQLite; use strict; use warnings; use base qw/DBIx::Class::Schema::Loader::DBI/; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use Text::Balanced qw( extract_bracketed ); use Class::C3; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm b/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm index f21800f..9837fd2 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm @@ -18,7 +18,7 @@ DBIx::Class::Schema::Loader::DBI::Writing - Loader subclass writing guide for DB use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI'; - use Carp::Clan qw/^DBIx::Class::Schema::Loader/; + use Carp::Clan qw/^DBIx::Class/; use Class::C3; sub _table_uniq_info { diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index cf2c0c9..1ab0107 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -3,7 +3,7 @@ package DBIx::Class::Schema::Loader::DBI::mysql; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI'; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use Class::C3; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index 7cc919c..f4a503f 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -2,7 +2,7 @@ package DBIx::Class::Schema::Loader::RelBuilder; use strict; use warnings; -use Carp::Clan qw/^DBIx::Class::Schema::Loader/; +use Carp::Clan qw/^DBIx::Class/; use Lingua::EN::Inflect (); use Lingua::EN::Inflect::Number (); diff --git a/t/20invocations.t b/t/20invocations.t new file mode 100644 index 0000000..22b0836 --- /dev/null +++ b/t/20invocations.t @@ -0,0 +1,135 @@ +use strict; +use Test::More; +use lib qw(t/lib); +use make_dbictest_db; + +# Takes a $schema as input, runs 4 basic tests +sub test_schema { + my ($testname, $schema) = @_; + + $schema = $schema->clone if !ref $schema; + isa_ok($schema, 'DBIx::Class::Schema', $testname); + + my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); + isa_ok($foo_rs, 'DBIx::Class::ResultSet', $testname); + + my $foo_first = $foo_rs->first; + like(ref $foo_first, qr/DBICTest::Schema::\d+::Foo/, $testname); + + my $foo_first_text = $foo_first->footext; + is($foo_first_text, 'Foo record associated with the Bar with barid 3'); +} + +my @invocations = ( + 'deprecated_one' => sub { + package DBICTest::Schema::1; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->connection($make_dbictest_db::dsn); + __PACKAGE__->load_from_connection( relationships => 1 ); + __PACKAGE__; + }, + 'deprecated_two' => sub { + package DBICTest::Schema::2; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->load_from_connection( + relationships => 1, + connect_info => [ $make_dbictest_db::dsn ], + ); + __PACKAGE__; + }, + 'deprecated_three' => sub { + package DBICTest::Schema::3; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->load_from_connection( + relationships => 1, + dsn => $make_dbictest_db::dsn, + ); + __PACKAGE__; + }, + 'deprecated_four' => sub { + package DBICTest::Schema::4; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->connection($make_dbictest_db::dsn); + __PACKAGE__->loader_options( relationships => 1 ); + __PACKAGE__; + }, + 'hardcode' => sub { + package DBICTest::Schema::5; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( relationships => 1 ); + __PACKAGE__->connection($make_dbictest_db::dsn); + __PACKAGE__; + }, + 'normal' => sub { + package DBICTest::Schema::6; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( relationships => 1 ); + __PACKAGE__->connect($make_dbictest_db::dsn); + }, + 'make_schema_at' => sub { + use DBIx::Class::Schema::Loader qw/ make_schema_at /; + make_schema_at( + 'DBICTest::Schema::7', + { relationships => 1 }, + [ $make_dbictest_db::dsn ], + ); + DBICTest::Schema::7->clone; + }, + 'embedded_options' => sub { + package DBICTest::Schema::8; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->connect( + $make_dbictest_db::dsn, + { loader_options => { relationships => 1 } } + ); + }, + 'embedded_options_in_attrs' => sub { + package DBICTest::Schema::9; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->connect( + $make_dbictest_db::dsn, + undef, + undef, + { AutoCommit => 1, loader_options => { relationships => 1 } } + ); + }, + 'embedded_options_make_schema_at' => sub { + use DBIx::Class::Schema::Loader qw/ make_schema_at /; + make_schema_at( + 'DBICTest::Schema::10', + { }, + [ + $make_dbictest_db::dsn, + { loader_options => { relationships => 1 } }, + ], + ); + "DBICTest::Schema::10"; + }, + 'almost_embedded' => sub { + package DBICTest::Schema::11; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( relationships => 1 ); + __PACKAGE__->connect( + $make_dbictest_db::dsn, + undef, undef, { AutoCommit => 1 } + ); + }, + 'make_schema_at_explicit' => sub { + use DBIx::Class::Schema::Loader; + DBIx::Class::Schema::Loader::make_schema_at( + 'DBICTest::Schema::12', + { relationships => 1 }, + [ $make_dbictest_db::dsn ], + ); + DBICTest::Schema::12->clone; + } +); + +# 4 tests per k/v pair +plan tests => 2 * @invocations; + +while(@invocations >= 2) { + my $style = shift @invocations; + my $subref = shift @invocations; + test_schema($style, &$subref); +} diff --git a/t/20invoke_deprecated_one.t b/t/20invoke_deprecated_one.t deleted file mode 100644 index da20e61..0000000 --- a/t/20invoke_deprecated_one.t +++ /dev/null @@ -1,29 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -package DBICTest::Schema; -use base qw/ DBIx::Class::Schema::Loader /; - -__PACKAGE__->connection("dbi:$class:dbname=./t/dbictest.db"); -__PACKAGE__->load_from_connection( relationships => 1 ); - -package main; - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->clone; -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->first; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); - diff --git a/t/21invoke_deprecated_two.t b/t/21invoke_deprecated_two.t deleted file mode 100644 index 6b3be2b..0000000 --- a/t/21invoke_deprecated_two.t +++ /dev/null @@ -1,31 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -package DBICTest::Schema; -use base qw/ DBIx::Class::Schema::Loader /; - -__PACKAGE__->load_from_connection( - relationships => 1, - connect_info => [ "dbi:$class:dbname=./t/dbictest.db" ], -); - -package main; - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->clone; -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->first; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); - diff --git a/t/21misc_fatal.t b/t/21misc_fatal.t new file mode 100644 index 0000000..e1627e0 --- /dev/null +++ b/t/21misc_fatal.t @@ -0,0 +1,26 @@ +use strict; +use Test::More; +use lib qw(t/lib); +use make_dbictest_db; + +{ + $INC{'DBIx/Class/Storage/xyzzy.pm'} = 1; + package DBIx::Class::Storage::xyzzy; + use base qw/ DBIx::Class::Storage /; + sub new { bless {}, shift } + sub connect_info { @_ } + + package DBICTest::Schema; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( relationships => 1 ); + __PACKAGE__->storage_type( '::xyzzy' ); +} + +plan tests => 1; + +eval { DBICTest::Schema->connect($make_dbictest_db::dsn) }; +like( + $@, + qr/Could not load storage_type loader "DBIx::Class::Schema::Loader::xyzzy": /, + 'Bad storage type dies correctly' +); diff --git a/t/22dump.t b/t/22dump.t new file mode 100644 index 0000000..5f6ff6a --- /dev/null +++ b/t/22dump.t @@ -0,0 +1,21 @@ +use strict; +use Test::More; +use lib qw(t/lib); +use make_dbictest_db; + +{ + package DBICTest::Schema; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( + relationships => 1, + dump_directory => './t/_dump', + dump_overwrite => 1, + ); + +} + +plan tests => 1; + +eval { DBICTest::Schema->connect($make_dbictest_db::dsn) }; +ok(!$@, 'no death with dump_directory set') + or diag "Dump failed: $@"; diff --git a/t/22invoke_deprecated_three.t b/t/22invoke_deprecated_three.t deleted file mode 100644 index 47ab3ed..0000000 --- a/t/22invoke_deprecated_three.t +++ /dev/null @@ -1,31 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -package DBICTest::Schema; -use base qw/ DBIx::Class::Schema::Loader /; - -__PACKAGE__->load_from_connection( - relationships => 1, - dsn => "dbi:$class:dbname=./t/dbictest.db", -); - -package main; - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->clone; -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->first; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); - diff --git a/t/23invoke_hardcode.t b/t/23invoke_hardcode.t deleted file mode 100644 index b65190d..0000000 --- a/t/23invoke_hardcode.t +++ /dev/null @@ -1,28 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -package DBICTest::Schema; -use base qw/ DBIx::Class::Schema::Loader /; - -__PACKAGE__->loader_options( relationships => 1 ); -__PACKAGE__->connection("dbi:$class:dbname=./t/dbictest.db"); - -package main; - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->clone; -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->first; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); diff --git a/t/24invoke_normal.t b/t/24invoke_normal.t deleted file mode 100644 index 087134e..0000000 --- a/t/24invoke_normal.t +++ /dev/null @@ -1,27 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -package DBICTest::Schema; -use base qw/ DBIx::Class::Schema::Loader /; - -__PACKAGE__->loader_options( relationships => 1 ); - -package main; - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->connect("dbi:$class:dbname=./t/dbictest.db"); -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->next; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); diff --git a/t/25invoke_inverse.t b/t/25invoke_inverse.t deleted file mode 100644 index 0ca4209..0000000 --- a/t/25invoke_inverse.t +++ /dev/null @@ -1,28 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -package DBICTest::Schema; -use base qw/ DBIx::Class::Schema::Loader /; - -__PACKAGE__->connection("dbi:$class:dbname=./t/dbictest.db"); -__PACKAGE__->loader_options( relationships => 1 ); - -package main; - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->clone; -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->first; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); diff --git a/t/26invoke_classmeth.t b/t/26invoke_classmeth.t deleted file mode 100644 index 59f758c..0000000 --- a/t/26invoke_classmeth.t +++ /dev/null @@ -1,28 +0,0 @@ -use strict; -use Test::More tests => 4; -use lib qw(t/lib); -use make_dbictest_db; - -eval { require DBD::SQLite }; -my $class = $@ ? 'SQLite2' : 'SQLite'; - -use DBIx::Class::Schema::Loader qw/ make_schema_at /; - -make_schema_at( - 'DBICTest::Schema', - { relationships => 1 }, - [ "dbi:$class:dbname=./t/dbictest.db" ], -); - -my $schema_class = 'DBICTest::Schema'; -my $schema = $schema_class->clone; -isa_ok($schema, 'DBIx::Class::Schema'); - -my $foo_rs = $schema->resultset('Bar')->search({ barid => 3})->search_related('fooref'); -isa_ok($foo_rs, 'DBIx::Class::ResultSet'); - -my $foo_first = $foo_rs->first; -isa_ok($foo_first, 'DBICTest::Schema::Foo'); - -my $foo_first_text = $foo_first->footext; -is($foo_first_text, 'This is the text of the only Foo record associated with the Bar with barid 3'); diff --git a/t/lib/make_dbictest_db.pm b/t/lib/make_dbictest_db.pm index a796ba9..6613288 100644 --- a/t/lib/make_dbictest_db.pm +++ b/t/lib/make_dbictest_db.pm @@ -10,8 +10,8 @@ my $class = $@ ? 'SQLite2' : 'SQLite'; my $fn = './t/dbictest.db'; unlink($fn); - -my $dbh = DBI->connect("dbi:$class:dbname=./t/dbictest.db"); +our $dsn = "dbi:$class:dbname=$fn"; +my $dbh = DBI->connect($dsn); $dbh->do($_) for ( q|CREATE TABLE foo ( @@ -23,7 +23,7 @@ $dbh->do($_) for ( fooref INTEGER REFERENCES foo(fooid) )|, q|INSERT INTO foo VALUES (1,'Foo text for number 1')|, - q|INSERT INTO foo VALUES (2,'This is the text of the only Foo record associated with the Bar with barid 3')|, + q|INSERT INTO foo VALUES (2,'Foo record associated with the Bar with barid 3')|, q|INSERT INTO foo VALUES (3,'Foo text for number 3')|, q|INSERT INTO foo VALUES (4,'Foo text for number 4')|, q|INSERT INTO bar VALUES (1,4)|,