From: Peter Rabbitson Date: Thu, 20 Nov 2008 11:01:14 +0000 (+0000) Subject: CDBI-compat tests by Dave Horwoth: X-Git-Tag: v0.08240~225 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c73f755dde710d850cbcc93d27b770174b342dd5;p=dbsrgits%2FDBIx-Class.git CDBI-compat tests by Dave Horwoth: OK. I've attached a patch to t/cdbi-t/15-accessor.t that does several things: (1) Fixes the way the arguments are built so the sheep argument is correct in the tests. (2) Adds explicit tests for the number of sheep so we can be sure which database record is actually returned. (3) Adds tests for find_or_create() with modified accessor names. (4) Fixes the test for search() to report all errors I still don't fully understand what's going on in the output below but I think they are genuine test failures. I'd appreciate it if somebody else could run the tests to make sure the results are not some artefact of my test environment. I also attached a copy of the modified test script so you don't even have to apply the patch first :) I don't know what the DestroyWarning at the end is all about. --- diff --git a/t/cdbi-t/15-accessor.t b/t/cdbi-t/15-accessor.t index 91d6145..ab7263d 100644 --- a/t/cdbi-t/15-accessor.t +++ b/t/cdbi-t/15-accessor.t @@ -8,7 +8,7 @@ BEGIN { next; } eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 55); + plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 75); } INIT { @@ -57,18 +57,60 @@ my $data = { }; eval { - my $data = $data; + my $data = { %$data }; $data->{NumExplodingSheep} = 1; ok my $bt = Film->create($data), "Modified accessor - with column name"; isa_ok $bt, "Film"; + is $bt->sheep, 1, 'sheep bursting violently'; }; is $@, '', "No errors"; eval { - my $data = $data; - $data->{sheep} = 1; + my $data = { %$data }; + $data->{sheep} = 2; ok my $bt = Film->create($data), "Modified accessor - with accessor"; isa_ok $bt, "Film"; + is $bt->sheep, 2, 'sheep bursting violently'; +}; +is $@, '', "No errors"; + +eval { + my $data = { %$data }; + $data->{NumExplodingSheep} = 1; + ok my $bt = Film->find_or_create($data), + "find_or_create Modified accessor - find with column name"; + isa_ok $bt, "Film"; + is $bt->sheep, 1, 'sheep bursting violently'; +}; +is $@, '', "No errors"; + +eval { + my $data = { %$data }; + $data->{sheep} = 1; + ok my $bt = Film->find_or_create($data), + "find_or_create Modified accessor - find with accessor"; + isa_ok $bt, "Film"; + is $bt->sheep, 1, 'sheep bursting violently'; +}; +is $@, '', "No errors"; + +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"; + is $bt->sheep, 3, 'sheep bursting violently'; +}; +is $@, '', "No errors"; + +eval { + my $data = { %$data }; + $data->{sheep} = 4; + ok my $bt = Film->find_or_create($data), + "find_or_create Modified accessor - create with accessor"; + isa_ok $bt, "Film"; + is $bt->sheep, 4, 'sheep bursting violently'; }; is $@, '', "No errors"; @@ -76,6 +118,7 @@ eval { my @film = Film->search({ sheep => 1 }); is @film, 2, "Can search with modified accessor"; }; +is $@, '', "No errors"; {