From: Peter Rabbitson Date: Fri, 19 Feb 2010 15:42:32 +0000 (+0000) Subject: Some test cleanups X-Git-Tag: v0.08120~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=56166f36313355d502a6517bf3316252d92d375a;p=dbsrgits%2FDBIx-Class.git Some test cleanups --- diff --git a/t/69update.t b/t/69update.t index 4686876..8b6fc28 100644 --- a/t/69update.t +++ b/t/69update.t @@ -7,11 +7,6 @@ use DBICTest; my $schema = DBICTest->init_schema(); -BEGIN { - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6); -} - my $art = $schema->resultset("Artist")->find(1); isa_ok $art => 'DBICTest::Artist'; @@ -20,10 +15,10 @@ my $name = 'Caterwauler McCrae'; ok($art->name($name) eq $name, 'update'); -{ +{ my @changed_keys = $art->is_changed; is( scalar (@changed_keys), 0, 'field changed but same value' ); -} +} $art->discard_changes; @@ -34,3 +29,5 @@ is($art->artistid, 100, 'pk mutation applied'); my $art_100 = $schema->resultset("Artist")->find(100); $art_100->artistid(101); ok($art_100->update(), 'update allows pk mutation via column accessor'); + +done_testing; diff --git a/t/75limit.t b/t/75limit.t index 881668d..686161a 100644 --- a/t/75limit.t +++ b/t/75limit.t @@ -7,11 +7,6 @@ use DBICTest; my $schema = DBICTest->init_schema(); -BEGIN { - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10); -} - # test LIMIT my $it = $schema->resultset("CD")->search( {}, { rows => 3, @@ -77,3 +72,4 @@ $it = $schema->resultset("CD")->search( ); is( $it->count, 1, "complex abstract count ok" ); +done_testing; diff --git a/t/76joins.t b/t/76joins.t index 0d5512e..862fef3 100644 --- a/t/76joins.t +++ b/t/76joins.t @@ -10,13 +10,6 @@ my $schema = DBICTest->init_schema(); my $orig_debug = $schema->storage->debug; -BEGIN { - eval "use DBD::SQLite"; - plan $@ - ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 33 ); -} - # test the abstract join => SQL generator my $sa = new DBIx::Class::SQLAHacks; @@ -240,3 +233,5 @@ is($rs->first->name, 'We Are Goth', 'Correct record returned'); is(cd_count(), 5, '5 rows in table cd'); is(tk_count(), 3, '3 rows in table twokeys'); } + +done_testing; diff --git a/t/bind/attribute.t b/t/bind/attribute.t index c4f99c4..ca00c30 100644 --- a/t/bind/attribute.t +++ b/t/bind/attribute.t @@ -9,13 +9,6 @@ use_ok('DBICTest'); my $schema = DBICTest->init_schema; -BEGIN { - eval "use DBD::SQLite"; - plan $@ - ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 13 ); -} - my $where_bind = { where => \'name like ?', bind => [ 'Cat%' ], @@ -122,3 +115,5 @@ TODO: { bind => [ 'Spoon%' ] }); is ( $rs->count, 1, '...cookbook + chained search with extra bind' ); } + +done_testing; diff --git a/t/sqlahacks/quotes/quotes.t b/t/sqlahacks/quotes/quotes.t index 398aa04..0b6716a 100644 --- a/t/sqlahacks/quotes/quotes.t +++ b/t/sqlahacks/quotes/quotes.t @@ -6,13 +6,6 @@ use Test::More; use lib qw(t/lib); use DBIC::SqlMakerTest; -BEGIN { - eval "use DBD::SQLite"; - plan $@ - ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 7 ); -} - use_ok('DBICTest'); use_ok('DBIC::DebugObj'); @@ -72,3 +65,5 @@ $schema->storage->sql_maker->quote_char('`'); $schema->storage->sql_maker->name_sep('.'); is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE'); + +done_testing; diff --git a/t/sqlahacks/quotes/quotes_newstyle.t b/t/sqlahacks/quotes/quotes_newstyle.t index ccf1445..6d448ea 100644 --- a/t/sqlahacks/quotes/quotes_newstyle.t +++ b/t/sqlahacks/quotes/quotes_newstyle.t @@ -6,13 +6,6 @@ use Test::More; use lib qw(t/lib); use DBIC::SqlMakerTest; -BEGIN { - eval "use DBD::SQLite"; - plan $@ - ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 7 ); -} - use_ok('DBICTest'); use_ok('DBIC::DebugObj'); @@ -89,3 +82,5 @@ $schema->connection( ); is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE'); + +done_testing; diff --git a/t/storage/error.t b/t/storage/error.t index 2efb8d5..e57d892 100644 --- a/t/storage/error.t +++ b/t/storage/error.t @@ -1,29 +1,20 @@ -use Class::C3; use strict; -use Test::More; use warnings; -BEGIN { - eval "use DBD::SQLite"; - plan $@ - ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 4 ); -} +use Test::More; +use Test::Warn; +use Test::Exception; use lib qw(t/lib); - use_ok( 'DBICTest' ); use_ok( 'DBICTest::Schema' ); + my $schema = DBICTest->init_schema; -{ - my $warnings; - local $SIG{__WARN__} = sub { $warnings .= $_[0] }; - eval { - $schema->resultset('CD') - ->create({ title => 'vacation in antarctica' }) - }; - like $@, qr/NULL/; # as opposed to some other error - unlike( $warnings, qr/uninitialized value/, "No warning from Storage" ); -} +warnings_are ( sub { + throws_ok (sub { + $schema->resultset('CD')->create({ title => 'vacation in antarctica' }); + }, qr/NULL/); # as opposed to some other error +}, [], 'No warnings besides exception' ); +done_testing;