From: Brendan Byrd Date: Thu, 22 Mar 2012 01:10:08 +0000 (-0400) Subject: Fix TODO tests to only mark exactly the failing tests as TODO X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9fd5c112aed0aa0734266ccbc2b66a3e37d62ce2;hp=dd5b7bd404adf28c65fb0c579a1058a71c4b64f2;p=dbsrgits%2FDBIx-Class-Historic.git Fix TODO tests to only mark exactly the failing tests as TODO and run the passing tests as real tests. --- diff --git a/t/752sqlite.t b/t/752sqlite.t index b5d11ca..1895a9f 100644 --- a/t/752sqlite.t +++ b/t/752sqlite.t @@ -96,7 +96,7 @@ DDL ); ok ($schema->storage->connected, 'Still connected'); { - local $TODO = 'SQLite is retarded wrt detecting COMMIT' if $c_commit; + local $TODO = 'SQLite is retarded wrt detecting COMMIT' if $c_commit and ! $c_begin; ok ($schema->storage->_dbh->{AutoCommit}, "DBD aware txn ended with comments on $prefix_comment"); } diff --git a/t/cdbi/15-accessor.t b/t/cdbi/15-accessor.t index 574292d..3dfbf41 100644 --- a/t/cdbi/15-accessor.t +++ b/t/cdbi/15-accessor.t @@ -89,13 +89,14 @@ eval { }; is $@, '', "No errors"; -TODO: { local $TODO = 'TODOifying failing tests, waiting for Schwern'; ok (1, 'remove me'); eval { my $data = { %$data }; $data->{NumExplodingSheep} = 3; ok my $bt = Film->find_or_create($data), "find_or_create Modified accessor - create with column name"; isa_ok $bt, "Film"; + + local $TODO = 'TODOifying failing tests, waiting for Schwern'; is $bt->sheep, 3, 'sheep bursting violently'; }; is $@, '', "No errors"; @@ -106,6 +107,8 @@ eval { ok my $bt = Film->find_or_create($data), "find_or_create Modified accessor - create with accessor"; isa_ok $bt, "Film"; + + local $TODO = 'TODOifying failing tests, waiting for Schwern'; is $bt->sheep, 4, 'sheep bursting violently'; }; is $@, '', "No errors"; @@ -114,8 +117,9 @@ eval { my @film = Film->search({ sheep => 1 }); is @film, 2, "Can search with modified accessor"; }; -is $@, '', "No errors"; - +{ + local $TODO = 'TODOifying failing tests, waiting for Schwern'; + is $@, '', "No errors"; } { diff --git a/t/multi_create/existing_in_chain.t b/t/multi_create/existing_in_chain.t index aa22503..292dd6b 100644 --- a/t/multi_create/existing_in_chain.t +++ b/t/multi_create/existing_in_chain.t @@ -28,35 +28,37 @@ my $schema = DBICTest->init_schema(); # # ribasushi -TODO: { my $f = __FILE__; local $TODO = "See comment at top of $f for discussion of the TODO"; +my $TODO_msg = "See comment at top of @{[ __FILE__ ]} for discussion of the TODO"; { my $counts; $counts->{$_} = $schema->resultset($_)->count for qw/Track CD Genre/; - lives_ok (sub { - my $existing_nogen_cd = $schema->resultset('CD')->search ( - { 'genre.genreid' => undef }, - { join => 'genre' }, - )->first; - - $schema->resultset('Track')->create ({ - title => 'Sugar-coated', - cd => { - title => $existing_nogen_cd->title, - genre => { - name => 'sugar genre', - } + my $existing_nogen_cd = $schema->resultset('CD')->search ( + { 'genre.genreid' => undef }, + { join => 'genre' }, + )->first; + + $schema->resultset('Track')->create ({ + title => 'Sugar-coated', + cd => { + title => $existing_nogen_cd->title, + genre => { + name => 'sugar genre', } - }); + } + }); - is ($schema->resultset('Track')->count, $counts->{Track} + 1, '1 new track'); - is ($schema->resultset('CD')->count, $counts->{CD}, 'No new cds'); - is ($schema->resultset('Genre')->count, $counts->{Genre} + 1, '1 new genre'); + is ($schema->resultset('Track')->count, $counts->{Track} + 1, '1 new track'); + is ($schema->resultset('CD')->count, $counts->{CD}, 'No new cds'); + TODO: { + todo_skip $TODO_msg, 1; + is ($schema->resultset('Genre')->count, $counts->{Genre} + 1, '1 new genre'); is ($existing_nogen_cd->genre->title, 'sugar genre', 'Correct genre assigned to CD'); - }, 'create() did not throw'); + } } + { my $counts; $counts->{$_} = $schema->resultset($_)->count for qw/Artist CD Producer/; @@ -89,6 +91,8 @@ TODO: { my $f = __FILE__; local $TODO = "See comment at top of $f for discussion is ($schema->resultset('Artist')->count, $counts->{Artist}, 'No new artists'); is ($schema->resultset('Producer')->count, $counts->{Producer} + 1, '1 new producers'); + + local $TODO = $TODO_msg; is ($schema->resultset('CD')->count, $counts->{CD} + 2, '2 new cds'); is ($producer->cds->count, 2, 'CDs assigned to correct producer'); @@ -100,6 +104,4 @@ TODO: { my $f = __FILE__; local $TODO = "See comment at top of $f for discussion }, 'create() did not throw'); } -} - done_testing; diff --git a/t/prefetch/multiple_hasmany.t b/t/prefetch/multiple_hasmany.t index a123208..cd86f17 100644 --- a/t/prefetch/multiple_hasmany.t +++ b/t/prefetch/multiple_hasmany.t @@ -4,7 +4,6 @@ use warnings; use Test::More; use lib qw(t/lib); use DBICTest; -use IO::File; my $schema = DBICTest->init_schema(); my $sdebug = $schema->storage->debug; @@ -39,7 +38,10 @@ TODO: { ok(! $o_mm_warn, 'no warning on attempt to prefetch several same level has_many\'s (1 -> M + M)'); + { + local $TODO; is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query'); + } $schema->storage->debugcb (undef); $schema->storage->debug ($sdebug); @@ -72,12 +74,16 @@ TODO: { ok(! $m_o_mm_warn, 'no warning on attempt to prefetch several same level has_many\'s (M -> 1 -> M + M)'); + { + local $TODO; + is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query'); $schema->storage->debugcb (undef); $schema->storage->debug ($sdebug); is($pr_tags_count, $tags_count, 'equal count of prefetched relations over several same level has_many\'s (M -> 1 -> M + M)'); is($pr_tags_rs->all, $tags_rs->all, 'equal amount of objects with and without prefetch over several same level has_many\'s (M -> 1 -> M + M)'); + } } # remove this closure once the TODO above is working diff --git a/t/prefetch/via_search_related.t b/t/prefetch/via_search_related.t index 1942c14..d838ad1 100644 --- a/t/prefetch/via_search_related.t +++ b/t/prefetch/via_search_related.t @@ -129,8 +129,6 @@ lives_ok (sub { is($rs->count, 1, 'distinct with prefetch (count)'); TODO: { - local $TODO = "This makes another 2 trips to the database, it can't be right"; - $queries = 0; $schema->storage->debugcb ($debugcb); $schema->storage->debug (1); @@ -139,6 +137,7 @@ lives_ok (sub { is($rs->search_related('cds')->all, 2, 'prefetched distinct with prefetch (objects)'); is($rs->search_related('cds')->count, 2, 'prefetched distinct with prefetch (count)'); + local $TODO = "This makes another 2 trips to the database, it can't be right"; is ($queries, 0, 'No extra queries fired (prefetch survives search_related)'); $schema->storage->debugcb (undef); diff --git a/t/row/inflate_result.t b/t/row/inflate_result.t index b020ab5..3ab2271 100644 --- a/t/row/inflate_result.t +++ b/t/row/inflate_result.t @@ -87,11 +87,11 @@ ok( ); TODO: { - local $TODO = 'New objects should also be inflated'; my $user = $schema->resultset('User')->create($user_data); my $admin = $schema->resultset('User')->create($admin_data); is( ref $user, 'My::Schema::Result::User' ); + local $TODO = 'New objects should also be inflated'; is( ref $admin, 'My::Schema::Result::User::Admin' ); }