Bug 14195

Summary: TestBuilder does not generate the good length for text fields
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: indradg, m.de.rooy, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14256
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 12603    
Bug Blocks: 14045    
Attachments: Bug 14105: TestBuilder - A random string should not be longer than the DB field
To reproduce the issue
[SIGNED-OFF] Bug 14195: TestBuilder - A random string should not be longer than the DB field
Bug 14195: (followup) increment number of tests
Bug 14195: TestBuilder - A random string should not be longer than the DB field
Bug 14195: (followup) increment number of tests

Description Jonathan Druart 2015-05-13 13:41:32 UTC
t::lib::TestBuilder::_gen_text does not use correctly the regex and the max parameter to generate the random string (String::Random).
Comment 1 Jonathan Druart 2015-05-13 14:42:30 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2015-05-13 14:44:35 UTC
Created attachment 39139 [details]
To reproduce the issue

Launch this script several times, without applying the patch.
If the generated string for categorycode has a length > 10, you will see a difference.

After applying the patch, the difference should never occur.
Comment 3 Bernardo Gonzalez Kriegel 2015-05-14 18:40:30 UTC Comment hidden (obsolete)
Comment 4 Bernardo Gonzalez Kriegel 2015-05-14 18:40:51 UTC Comment hidden (obsolete)
Comment 5 Marcel de Rooy 2015-05-19 12:59:06 UTC
Small question before passing QA: why do you decrement $size here:

+    if ( defined $size and $size > 1 ) {
+        $size--;
Comment 6 Jonathan Druart 2015-05-19 14:36:09 UTC
(In reply to Marcel de Rooy from comment #5)
> Small question before passing QA: why do you decrement $size here:
> 
> +    if ( defined $size and $size > 1 ) {
> +        $size--;

Because the regex, in this case, is
    [A-Za-z][A-Za-z0-9_]*
And the max size passed to String::Random is related to the wild card, not the the size of the complete string.
Comment 7 Marcel de Rooy 2015-05-20 11:18:38 UTC
Created attachment 39340 [details] [review]
Bug 14195: TestBuilder - A random string should not be longer than the DB field

t::lib::TestBuilder::_gen_text does not use correctly the regex and the
max parameter to generate the random string (String::Random).

This can cause future tests to fail.

http://bugs.koha-community.org/show_bug.cgi?id=14195
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Script tested, problem occurs, patch fixes it.
Bad number on commit subject
No errors

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Marcel de Rooy 2015-05-20 11:18:43 UTC
Created attachment 39341 [details] [review]
Bug 14195: (followup) increment number of tests

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2015-05-20 11:20:18 UTC
(In reply to Jonathan Druart from comment #6)

> Because the regex, in this case, is
>     [A-Za-z][A-Za-z0-9_]*
> And the max size passed to String::Random is related to the wild card, not
> the the size of the complete string.

Fine. Could have read this in your comment :) Just not very intuitive Random parameter.. Thanks.
Comment 10 Tomás Cohen Arazi 2015-05-20 14:23:30 UTC
Patch pushed to master.

Thanks Jonathan!