Bugzilla – Attachment 144234 Details for
Bug 32350
We should die if TestBuilder is passed a column we're not expecting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32350: Use array_minus and ignore nesting
Bug-32350-Use-arrayminus-and-ignore-nesting.patch (text/plain), 2.29 KB, created by
Marcel de Rooy
on 2022-11-25 10:22:44 UTC
(
hide
)
Description:
Bug 32350: Use array_minus and ignore nesting
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-11-25 10:22:44 UTC
Size:
2.29 KB
patch
obsolete
>From 1ee0fcc71eefa8d8abab0f7a54ccbb2c29a16849 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 25 Nov 2022 10:02:24 +0000 >Subject: [PATCH] Bug 32350: Use array_minus and ignore nesting >Content-Type: text/plain; charset=utf-8 > >Note: Test will be extended in follow-up. This fixes the >module_bit hash to follow the FK path from user_permissions >to permissions to userflags. One step was missed in the >existing test, although it did not fail. The change here >revealed that now. > >Test plan: >Run t/db_dependent/TestBuilder.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/TestBuilder.t | 4 +++- > t/lib/TestBuilder.pm | 8 ++++---- > 2 files changed, 7 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index c256fe53fc..30588da103 100755 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -244,7 +244,9 @@ sub default_userpermission { > privacy => 1, > }, > module_bit => { >- flag => 'my flag', >+ module_bit => { >+ flag => 'my flag', >+ }, > }, > code => { > code => 'my code', >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index bac6e3818e..fedcdc718d 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -13,6 +13,7 @@ use Carp qw( carp ); > use Module::Load qw( load ); > use String::Random; > use List::Util qw( any ); >+use Array::Utils qw( array_minus ); > > use constant { > SIZE_BARCODE => 20, # Not perfect but avoid to fetch the value when creating a new item >@@ -281,10 +282,9 @@ sub _buildColumnValues { > my @columns = $self->schema->source($source)->columns; > my %unique_constraints = $self->schema->source($source)->unique_constraints(); > >- for my $key ( keys %{$original_value} ) { >- die "value passed for unrecognised column: $key" >- if !( any { $key eq $_ } @columns ); >- } >+ my @passed_keys = grep { ref($original_value->{$_}) ne 'HASH' } keys %$original_value; >+ my @minus = array_minus( @passed_keys, @columns ); >+ die "Error: value hash contains unrecognized columns: ". (join ',', @minus) if @minus; > > my $build_value = 5; > # we try max $build_value times if there are unique constraints >-- >2.30.2
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 32350
:
144229
|
144230
|
144233
|
144234
|
144235
|
144239
|
144245
|
144246
|
144247
|
144248
|
144276
|
144277
|
144349
|
144350