From 2e117b6f0e723299a40d70d7157434938f2245a8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Oct 2017 11:29:06 -0300 Subject: [PATCH] Bug 19463: Reduce the chance to have TestBuilder generate twice the same value Content-Type: text/plain; charset=utf-8 When an id is generated by TestBuilder (branchcode for instance) and the size of the generated string is 1, we have too many chances to get "Violation of unique constraint in Branch". This patch increases the number of retries to 5. Signed-off-by: Marcel de Rooy Amended to make room for follow-up. --- t/lib/TestBuilder.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 4dab423..a412846 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -188,8 +188,8 @@ sub _buildColumnValues { my @columns = $self->schema->source($source)->columns; my %unique_constraints = $self->schema->source($source)->unique_constraints(); - my $build_value = 3; - # we try max three times if there are unique constraints + my $build_value = 5; + # we try max $build_value times if there are unique constraints BUILD_VALUE: while ( $build_value ) { # generate random values for all columns for my $col_name( @columns ) { @@ -442,7 +442,8 @@ sub _gen_text { $regex = '[A-Za-z]'; } my $random = String::Random->new( max => $size ); - return $random->randregex($regex); + my $text = $random->randregex($regex); + return $text; } sub _gen_set_enum { -- 2.1.4