Baby Moose Clean Up
It is test catch up day here in the Moose-pen.
I figured it is a good thing to review the state of the test suites for both Database::Accessor and Driver::DBI and starting with Accessor.pm I get this;
t/20_dad_load.t (Wstat: 1024 Tests: 53 Failed: 7)
Failed tests: 6, 12, 18, 24, 51-53
Parse errors: Bad plan. You planned 50 tests but ran 53.
t/30_view.t (Wstat: 256 Tests: 9 Failed: 1)
Failed test: 5
Parse errors: Bad plan. You planned 10 tests but ran 9.
t/31_elements.t (Wstat: 65280 Tests: 19 Failed: 5)
Failed tests: 15-19
Parse errors: Bad plan. You planned 14 tests but ran 19.
t/39_sorts.t (Wstat: 65280 Tests: 7 Failed: 1)
Failed test: 7
Parse errors: Bad plan. You planned 11 tests but ran 7.
t/52_delete.t (Wstat: 768 Tests: 9 Failed: 3)
Failed tests: 5-7
Non-zero exit status: 3
t/54_update.t (Wstat: 512 Tests: 6 Failed: 3)
Failed tests: 4-6
Parse errors: Bad plan. You planned 8 tests but ran 6.
t/62_crud_options.t (Wstat: 65280 Tests: 6 Failed: 3)
Failed tests: 4-6
Parse errors: Bad plan. You planned 3 tests but ran 6.
lets reset the test counts and run it again and we get
t/20_dad_load.t (Wstat: 1024 Tests: 53 Failed: 4)
Failed tests: 3, 18, 24, 30
Non-zero exit status: 4
t/30_view.t (Wstat: 256 Tests: 9 Failed: 1)
Failed test: 5
Non-zero exit status: 1
t/52_delete.t (Wstat: 768 Tests: 9 Failed: 3)
Failed tests: 5-7
Non-zero exit status: 3
t/54_update.t (Wstat: 512 Tests: 6 Failed: 3)
Failed tests: 4-6
Non-zero exit status: 2
Looking at 20_dad_load.t first the fix was a simple enough. It was failing because most of my DAD flags are now RW vs RO. The fix was easy enough, I created a hash where the keys are the attributes that are now RW and then I check that with the attribute name against the hash and do the appropriate test;
…
++my %read_write = (da_compose_only=>1,
++ da_no_effect=>1,
++ da_raise_error_off=>1,
++ da_warning=>1);
my $dad_role = consuming_class("Database::Accessor::Roles::Driver");
…
++ if (exists($read_write{$attribute->name()})){
++ ok( $attr->get_write_method ,
++ "Role DAD attribute: $dad_attribute is Read Write" );
++ }
++ else {
ok( !$attr->get_write_method ,
"Role DAD attribute: $dad_attribute is Read Only" );
++ }
…
I also added in a change in Accessor.pm where I consolidated the code a little;
...
qw(da_compose_only
da_no_effect
+ da_raise_error_off
)
...
- has da_raise_error_off => (
- is => 'rw',
- isa => 'Bool',
- default => 0,
- traits => ['ENV'],
- );
…
and I get 100% pass on that test.
The next '30_view.t' was again a simple fix. The fail was;
not ok 5 - View is Required
and a quick check and my attribute in Accessor.pm and I needed to add this;
has view => (
is => 'ro',
isa => 'View',
+ required => 1
);
and all my test pass on that one.
Next we have '52_delete.t' with a few fails and after a little extra debugging added in and in a few mins I found;
not ok 5 - Database::Accessor->delete Unbalanced parentheses in your conditions and dynamic_conditions. Please check them! at /home/scolesj/database-accessor/lib/Database/Accessor.pm line 742.
# Can delete with only static condition
So I think this is just some bad data in the test and this change in the test data in there;
right => { value => 'test' },
operator => '=',
- open_parentheses => 1,
- close_parentheses => 0,
condition => 'AND',
}
and all my tests pass;
Finally there is '54_update.t' after chasing my tail for a few mins I finally found that is was the same parentheses problem as '52_delete' and when I fixed that I and clean up a few more tests count and fix this
t/35_links.t ................ Use of uninitialized value in string ne at /home/scolesj/database-accessor/lib/Database/Accessor.pm line 724.
anoying warning with this little bit of code
- $element->view ne $self->view->name
- and $element->view ne $self->view->alias
+ $element->view ne $self->view->name
+ and $self->view->alias
and $element->view ne $self->view->alias
I get a full pass. So back on track again. Though I really haven't played with Driver::DBI much over the past few days.
Leave a comment