Bugzilla – Attachment 129616 Details for
Bug 29862
TestBuilder.t fails with ES enabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29862: Add missing txn begin/rollback in TestBuilder.t
Bug-29862-Add-missing-txn-beginrollback-in-TestBui.patch (text/plain), 7.64 KB, created by
Martin Renvoize (ashimema)
on 2022-01-19 15:40:04 UTC
(
hide
)
Description:
Bug 29862: Add missing txn begin/rollback in TestBuilder.t
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-01-19 15:40:04 UTC
Size:
7.64 KB
patch
obsolete
>From 52fff38352db9d2907db8560513c16e8e1c37936 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 17 Jan 2022 11:40:00 +0100 >Subject: [PATCH] Bug 29862: Add missing txn begin/rollback in TestBuilder.t > >It fixes the tests when SearchEngine=ES > t/db_dependent/TestBuilder.t .. 7/15 Invalid MARC field expression: l5ffglZ_upqqcwOvaiyALgXfyJw2Ot2AGRPUsiAPzSFHfd8J_hsnuQ8z75B8RKc_kyo2rFBp8BrPNwcM1FPhc01ngP01HU_Z7Rx1VHfcIcmrifYnjBDWNmYB9N5_4xEnxMH7ZhqC9b2Bz9wf9 > wSEmx64x6t5xFFKX at /kohadevbox/koha/C4/Biblio.pm line 306. > # Looks like you planned 12 tests but ran 6. > > # Failed test 'Tests for delete method' > # at t/db_dependent/TestBuilder.t line 302. > Can't call method "biblionumber" on an undefined value at t/db_dependent/TestBuilder.t line 281. > # Looks like your test exited with 11 just after 8. > >Previous subtest created invalid date in the ES mappings. > >Test plan: >Set SearchEngine=ES and run the tests, they must pass. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/TestBuilder.t | 52 +++++++++++++++++++++++++++++++++--- > 1 file changed, 48 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index f4777c8a16..c256fe53fc 100755 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -33,12 +33,13 @@ BEGIN { > } > > our $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; > our $builder; > > subtest 'Start with some trivial tests' => sub { > plan tests => 7; > >+ $schema->storage->txn_begin; >+ > $builder = t::lib::TestBuilder->new; > isnt( $builder, undef, 'We got a builder' ); > >@@ -61,12 +62,16 @@ subtest 'Start with some trivial tests' => sub { > warning_like { $builder->build( $param ) } > qr/Violation of unique constraint/, > 'Catch warn on adding existing record'; >+ >+ $schema->storage->txn_rollback; > }; > > > subtest 'Build all sources' => sub { > plan tests => 1; > >+ $schema->storage->txn_begin; >+ > my @sources = $builder->schema->sources; > my @source_in_failure; > for my $source ( @sources ) { >@@ -82,12 +87,16 @@ subtest 'Build all sources' => sub { > diag( "The following sources have not been generated correctly: " . > join ', ', @source_in_failure ); > } >+ >+ $schema->storage->txn_rollback; > }; > > > subtest 'Test length of some generated fields' => sub { > plan tests => 3; > >+ $schema->storage->txn_begin; >+ > # Test the length of a returned character field > my $bookseller = $builder->build({ source => 'Aqbookseller' }); > my $max = $schema->source('Aqbookseller')->column_info('phone')->{size}; >@@ -98,12 +107,16 @@ subtest 'Test length of some generated fields' => sub { > > my $item = $builder->build({ source => 'Item' }); > is( $item->{replacementprice}, sprintf("%.2f", $item->{replacementprice}), "The number of decimals for floats should not be more than 2" ); >+ >+ $schema->storage->txn_rollback; > }; > > > subtest 'Test FKs in overduerules_transport_type' => sub { > plan tests => 5; > >+ $schema->storage->txn_begin; >+ > my $my_overduerules_transport_type = { > message_transport_type => { > message_transport_type => 'my msg_t_t', >@@ -143,12 +156,16 @@ subtest 'Test FKs in overduerules_transport_type' => sub { > undef, > 'build generates values if they are not given' > ); >+ >+ $schema->storage->txn_rollback; > }; > > > subtest 'Tests with composite FK in userpermission' => sub { > plan tests => 9; > >+ $schema->storage->txn_begin; >+ > my $my_user_permission = default_userpermission(); > my $user_permission = $builder->build({ > source => 'UserPermission', >@@ -206,6 +223,8 @@ subtest 'Tests with composite FK in userpermission' => sub { > $my_user_permission->{code}->{description}, > 'build stored description correctly' > ); >+ >+ $schema->storage->txn_rollback; > }; > > sub default_userpermission { >@@ -238,6 +257,8 @@ sub default_userpermission { > subtest 'Test build with NULL values' => sub { > plan tests => 3; > >+ $schema->storage->txn_begin; >+ > # PK should not be null > my $params = { source => 'Branch', value => { branchcode => undef }}; > warning_like { $builder->build( $params ) } >@@ -255,12 +276,16 @@ subtest 'Test build with NULL values' => sub { > $info = $schema->source( 'Reserve' )->column_info( 'itemnumber' ); > is( $reserve && $info->{is_nullable} && $info->{is_foreign_key} && > !defined( $reserve->{itemnumber} ), 1, 'Nullable FK' ); >+ >+ $schema->storage->txn_rollback; > }; > > > subtest 'Tests for delete method' => sub { > plan tests => 12; > >+ $schema->storage->txn_begin; >+ > # Test delete with single and multiple records > my $basket1 = $builder->build({ source => 'Aqbasket' }); > my $basket2 = $builder->build({ source => 'Aqbasket' }); >@@ -299,12 +324,15 @@ subtest 'Tests for delete method' => sub { > code => undef }; > is( $builder->delete({ source => 'Permission', records => $val }), 0, > 'delete returns zero for an undef search with a composite PK' ); >-}; > >+ $schema->storage->txn_rollback; >+}; > > subtest 'Auto-increment values tests' => sub { > plan tests => 3; > >+ $schema->storage->txn_begin; >+ > # Pick a table with AI PK > my $source = 'Biblio'; # table > my $column = 'biblionumber'; # ai column >@@ -328,21 +356,29 @@ subtest 'Auto-increment values tests' => sub { > value => { biblionumber => 123 }, > }) } qr/^Value not allowed for auto_incr/, > 'Build should not overwrite an auto_incr column'; >+ >+ $schema->storage->txn_rollback; > }; > > subtest 'Date handling' => sub { > plan tests => 2; > >+ $schema->storage->txn_begin; >+ > $builder = t::lib::TestBuilder->new; > > my $patron = $builder->build( { source => 'Borrower' } ); > is( length( $patron->{updated_on} ), 19, 'A timestamp column value should be YYYY-MM-DD HH:MM:SS' ); > is( length( $patron->{dateofbirth} ), 10, 'A date column value should be YYYY-MM-DD' ); >+ >+ $schema->storage->txn_rollback; > }; > > subtest 'Default values' => sub { > plan tests => 3; > >+ $schema->storage->txn_begin; >+ > $builder = t::lib::TestBuilder->new; > my $item = $builder->build( { source => 'Item' } ); > is( $item->{more_subfields_xml}, undef, 'This xml field should be undef' ); >@@ -358,12 +394,16 @@ subtest 'Default values' => sub { > $patron = $builder->build_object({ class => 'Koha::Patrons', value => {categorycode => $patron_category_X->categorycode} }); > is( $patron->category->category_type, 'X', ); > }; >+ >+ $schema->storage->txn_rollback; > }; > > subtest 'build_object() tests' => sub { > > plan tests => 5; > >+ $schema->storage->txn_begin; >+ > $builder = t::lib::TestBuilder->new(); > > my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >@@ -428,11 +468,15 @@ subtest 'build_object() tests' => sub { > { class => 'Koha::Patrons', categorycode => 'foobar' } ); > } qr{Unknown parameter\(s\): categorycode}, "Unknown parameter detected"; > }; >+ >+ $schema->storage->txn_rollback; > }; > > subtest '->build parameter' => sub { > plan tests => 4; > >+ $schema->storage->txn_begin; >+ > # Test to make sure build() warns user of unknown parameters. > warnings_are { > $builder->build({ >@@ -460,9 +504,9 @@ subtest '->build parameter' => sub { > $builder->build( > { source => 'Borrower', categorycode => 'foobar' } ); > } qr{Unknown parameter\(s\): categorycode}, "Unkown parameter detected"; >-}; > >-$schema->storage->txn_rollback; >+ $schema->storage->txn_rollback; >+}; > > subtest 'build_sample_biblio() tests' => sub { > >-- >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 29862
:
129522
| 129616