Bugzilla – Attachment 66924 Details for
Bug 15339
TestBuilder build parameter warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15339: [QA Follow-up] Add a warning too when source is not supplied
Bug-15339-QA-Follow-up-Add-a-warning-too-when-sour.patch (text/plain), 2.92 KB, created by
Marcel de Rooy
on 2017-09-07 10:10:16 UTC
(
hide
)
Description:
Bug 15339: [QA Follow-up] Add a warning too when source is not supplied
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-09-07 10:10:16 UTC
Size:
2.92 KB
patch
obsolete
>From f1ac424c6ba727323aa1f9374228090996157812 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 7 Sep 2017 09:24:28 +0200 >Subject: [PATCH] Bug 15339: [QA Follow-up] Add a warning too when source is > not supplied >Content-Type: text/plain; charset=utf-8 > >When you do not supply a source and add a few wrong parameters, you >would not be warned. Because build simply returns undef. >Adding a carp and a test for that situation too. > >Note: In the earlier subtest 'trivial tests' build was called without >source. This now generates a warning. We just catch if there is a warning >and test the actual warning itself later on. > >Test plan: >Run t/db_dependent/TestBuilder.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/TestBuilder.t | 14 +++++++++++--- > t/lib/TestBuilder.pm | 6 +++++- > 2 files changed, 16 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index 5ef269f..c3ea95c 100644 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -36,12 +36,14 @@ our $builder; > > > subtest 'Start with some trivial tests' => sub { >- plan tests => 6; >+ plan tests => 7; > > $builder = t::lib::TestBuilder->new; > isnt( $builder, undef, 'We got a builder' ); > >- is( $builder->build, undef, 'build without arguments returns undef' ); >+ my $data; >+ warning_like { my $data = $builder->build; } qr/.+/, 'Catch a warning'; >+ is( $data, undef, 'build without arguments returns undef' ); > is( ref( $builder->schema ), 'Koha::Schema', 'check schema' ); > is( ref( $builder->can('delete') ), 'CODE', 'found delete method' ); > >@@ -391,7 +393,7 @@ subtest 'build_object() tests' => sub { > }; > > subtest '->build parameter' => sub { >- plan tests => 2; >+ plan tests => 3; > > # Test to make sure build() warns user of unknown parameters. > warnings_are { >@@ -409,6 +411,12 @@ subtest '->build parameter' => sub { > branchcode => 'BRANCH_2' # This is wrong! > }) > } qr/unknown param/i, "Carp unknown parameters"; >+ >+ warnings_like { >+ $builder->build({ >+ zource => 'Branch', # Intentional spelling error >+ }) >+ } qr/Source parameter not specified/, "Catch warning on missing source"; > }; > > $schema->storage->txn_rollback; >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 1b56f92..2693e9c 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -86,7 +86,11 @@ sub build { > # build returns a hash of column values for a created record, or undef > # build does NOT update a record, or pass back values of an existing record > my ($self, $params) = @_; >- my $source = $params->{source} || return; >+ my $source = $params->{source}; >+ if( !$source ) { >+ carp "Source parameter not specified!"; >+ return; >+ } > my $value = $params->{value}; > > my @unknowns = grep( !/^(source|value)$/, keys %{ $params }); >-- >2.1.4
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 15339
:
45527
|
45528
|
66892
|
66893
|
66894
|
66921
|
66922
|
66923
| 66924 |
66951