Bugzilla – Attachment 95550 Details for
Bug 24062
Circulation tests fail randomly if patron category type is 'X'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24062: Make sure TestBuilder will stop generate X or other invalid category's types
Bug-24062-Make-sure-TestBuilder-will-stop-generate.patch (text/plain), 3.09 KB, created by
Marcel de Rooy
on 2019-11-19 13:46:23 UTC
(
hide
)
Description:
Bug 24062: Make sure TestBuilder will stop generate X or other invalid category's types
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-11-19 13:46:23 UTC
Size:
3.09 KB
patch
obsolete
>From 539c670734552ac8bf2a13e2b1ec25db4a0a32be Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Nov 2019 10:14:31 +0100 >Subject: [PATCH] Bug 24062: Make sure TestBuilder will stop generate X or > other invalid category's types >Content-Type: text/plain; charset=utf-8 > >To make sure this kind of random failures will not appear in a future we >are going to fix it at TestBuilder level. > >Test plan: > prove t/db_dependent/TestBuilder.t >and confirm it returns green > >You could also only apply the tests against master, run them several >times and confirm that they fail most of the time. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/TestBuilder.t | 13 ++++++++++++- > t/lib/TestBuilder.pm | 6 +++++- > 2 files changed, 17 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index 1e02e7145c..e8cfeb9e4d 100644 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -339,12 +339,23 @@ subtest 'Date handling' => sub { > }; > > subtest 'Default values' => sub { >- plan tests => 2; >+ plan tests => 3; >+ > $builder = t::lib::TestBuilder->new; > my $item = $builder->build( { source => 'Item' } ); > is( $item->{more_subfields_xml}, undef, 'This xml field should be undef' ); > $item = $builder->build( { source => 'Item', value => { more_subfields_xml => 'some xml' } } ); > is( $item->{more_subfields_xml}, 'some xml', 'Default should not overwrite assigned value' ); >+ >+ subtest 'generated dynamically (coderef)' => sub { >+ plan tests => 2; >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ like( $patron->category->category_type, qr{^(A|C|S|I|P|)$}, ); >+ >+ my $patron_category_X = $builder->build_object({ class => 'Koha::Patron::Categories', value => { category_type => 'X' } }); >+ $patron = $builder->build_object({ class => 'Koha::Patrons', value => {categorycode => $patron_category_X->categorycode} }); >+ is( $patron->category->category_type, 'X', ); >+ }; > }; > > subtest 'build_object() tests' => sub { >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 7ffd02f76e..7b5a6bbc72 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -401,7 +401,9 @@ sub _buildColumnValue { > } > push @$retvalue, $value->{$col_name}; > } elsif( exists $self->{default_values}{$source}{$col_name} ) { >- push @$retvalue, $self->{default_values}{$source}{$col_name}; >+ my $v = $self->{default_values}{$source}{$col_name}; >+ $v = &$v() if ref($v) eq 'CODE'; >+ push @$retvalue, $v; > } else { > my $data_type = $col_info->{data_type}; > $data_type =~ s| |_|; >@@ -550,6 +552,8 @@ sub _gen_default_values { > Category => { > enrolmentfee => 0, > reservefee => 0, >+ # Not X, used for statistics >+ category_type => sub { return [ qw( A C S I P ) ]->[int(rand(5))] }, > }, > Itemtype => { > rentalcharge => 0, >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24062
:
95524
|
95525
|
95526
|
95541
|
95542
|
95543
|
95549
| 95550