Bugzilla – Attachment 69566 Details for
Bug 19759
TestBuilder generates too many decimals for float
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19759: Make TestBuilder generates only 2 decimals for float
Bug-19759-Make-TestBuilder-generates-only-2-decima.patch (text/plain), 1.99 KB, created by
Jonathan Druart
on 2017-12-06 16:44:53 UTC
(
hide
)
Description:
Bug 19759: Make TestBuilder generates only 2 decimals for float
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-12-06 16:44:53 UTC
Size:
1.99 KB
patch
obsolete
>From cd8f7a617d85374edbd7097a5c48d3f44509d02a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 6 Dec 2017 13:03:15 -0300 >Subject: [PATCH] Bug 19759: Make TestBuilder generates only 2 decimals for > float > >For instance items.replacementprice is decimal(8,2) but more than 2 decimals are generated. > >It leads to issues when we compare expected objects: > > # got: '135623.866142537' > # expected: '135623.87' > >Test plan: > prove t/db_dependent/TestBuilder.t >must return green >--- > t/db_dependent/TestBuilder.t | 5 ++++- > t/lib/TestBuilder.pm | 2 +- > 2 files changed, 5 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index 1a2c2fda3c..5ee0a6a40b 100644 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -85,7 +85,7 @@ subtest 'Build all sources' => sub { > > > subtest 'Test length of some generated fields' => sub { >- plan tests => 2; >+ plan tests => 3; > > # Test the length of a returned character field > my $bookseller = $builder->build({ source => 'Aqbookseller' }); >@@ -94,6 +94,9 @@ subtest 'Test length of some generated fields' => sub { > 'The length for a generated string (phone) should not be zero' ); > is( length( $bookseller->{phone} ) <= $max, 1, > 'Check maximum length for a generated string (phone)' ); >+ >+ my $item = $builder->build({ source => 'Item' }); >+ is( $item->{replacementprice}, sprintf("%.2f", $item->{replacementprice}), "The number of decimals for floats should not be more than 2" ); > }; > > >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 4ec6dba574..d42cb03346 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -417,7 +417,7 @@ sub _gen_real { > if( defined( $params->{info}->{size} ) ) { > $max = 10 ** ($params->{info}->{size}->[0] - $params->{info}->{size}->[1]); > } >- return rand($max) + 1; >+ return sprintf("%.2f", rand($max)+1); > } > > sub _gen_date { >-- >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 19759
:
69562
|
69566
|
69666
|
69821
|
69861