Bugzilla – Attachment 144247 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: Add subtest for bad columns
Bug-32350-Add-subtest-for-bad-columns.patch (text/plain), 2.16 KB, created by
Martin Renvoize (ashimema)
on 2022-11-25 11:44:55 UTC
(
hide
)
Description:
Bug 32350: Add subtest for bad columns
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-11-25 11:44:55 UTC
Size:
2.16 KB
patch
obsolete
>From 0818c002722057246580d231c10fd40120597dea Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 25 Nov 2022 10:09:57 +0000 >Subject: [PATCH] Bug 32350: Add subtest for bad columns > >Test plan: >Run t/db_dependent/TestBuilder.t >And now run the whole test suite :) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/TestBuilder.t | 35 ++++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index 30588da103..1fa63d0ae1 100755 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -21,8 +21,9 @@ use Modern::Perl; > > use utf8; > >-use Test::More tests => 15; >+use Test::More tests => 16; > use Test::Warn; >+use Try::Tiny; > use File::Basename qw(dirname); > > use Koha::Database; >@@ -544,3 +545,35 @@ subtest 'Existence of object is only checked using primary keys' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'Test bad columns' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ try { >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { wrong => 1 } }); >+ ok( 0, 'Unexpected pass with wrong column' ); >+ } >+ catch { >+ like( $_, qr/^Error: value hash contains unrecognized columns: wrong/, 'Column wrong is bad' ); >+ }; >+ try { >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { surname => 'Pass', nested => { ignored => 1 }} }); >+ ok( 1, 'Nested hash ignored' ); >+ } >+ catch { >+ ok( 0, 'Unexpected trouble with nested hash' ); >+ }; >+ try { >+ my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { surname => 'WontPass', categorycode => { description => 'bla', wrong_nested => 1 }}, >+ }); >+ ok( 0, 'Unexpected pass with wrong nested column' ); >+ } >+ catch { >+ like( $_, qr/^Error: value hash contains unrecognized columns: wrong_nested/, 'Column wrong_nested is bad' ); >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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