Bug 28966: (QA follow-up) Fix failing unit tests
Test Plan: 1) prove t/db_dependent/TestBuilder.t 2) Note tests fail 3) Apply this patch 4) Run updatedatabase.pl 5) Update the schema files ( alias 'dbic' can be used in koha-testing-docker ) 6) prove t/db_dependent/TestBuilder.t 7) Tests now pass! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
328baf44b4
commit
c195ffa9b1
3 changed files with 28 additions and 12 deletions
18
installer/data/mysql/atomicupdate/bug_32966.pl
Executable file
18
installer/data/mysql/atomicupdate/bug_32966.pl
Executable file
|
@ -0,0 +1,18 @@
|
|||
use Modern::Perl;
|
||||
|
||||
return {
|
||||
bug_number => "28966",
|
||||
description => "Holds queue view too slow to load for large numbers of holds",
|
||||
up => sub {
|
||||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
||||
|
||||
unless ( primary_key_exists( 'tmp_holdsqueue', 'itemnumber' ) ) {
|
||||
$dbh->do(
|
||||
q{ALTER TABLE tmp_holdsqueue ADD PRIMARY KEY (itemnumber)}
|
||||
);
|
||||
}
|
||||
|
||||
say $out "Set primary key for table 'tmp_holdsqueue' to 'itemnumber'";
|
||||
},
|
||||
};
|
|
@ -5885,6 +5885,7 @@ CREATE TABLE `tmp_holdsqueue` (
|
|||
`notes` mediumtext DEFAULT NULL,
|
||||
`item_level_request` tinyint(4) NOT NULL DEFAULT 0,
|
||||
`timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this entry as added/last updated',
|
||||
PRIMARY KEY (`itemnumber`),
|
||||
KEY `tmp_holdsqueue_ibfk_1` (`itemnumber`),
|
||||
KEY `tmp_holdsqueue_ibfk_2` (`biblionumber`),
|
||||
KEY `tmp_holdsqueue_ibfk_3` (`borrowernumber`),
|
||||
|
|
|
@ -285,7 +285,7 @@ subtest 'Test build with NULL values' => sub {
|
|||
|
||||
|
||||
subtest 'Tests for delete method' => sub {
|
||||
plan tests => 12;
|
||||
plan tests => 11;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
@ -304,23 +304,20 @@ subtest 'Tests for delete method' => sub {
|
|||
|
||||
|
||||
# Test delete in table without primary key (..)
|
||||
is( $schema->source('TmpHoldsqueue')->primary_columns, 0,
|
||||
is( $schema->source('AccountCreditTypesBranch')->primary_columns, 0,
|
||||
'Table without primary key detected' );
|
||||
my $bibno = $builder->build_sample_biblio->biblionumber;
|
||||
my $cnt1 = $schema->resultset('TmpHoldsqueue')->count;
|
||||
# Insert a new record in TmpHoldsqueue with that biblionumber
|
||||
my $val = { biblionumber => $bibno };
|
||||
my $rec = $builder->build({ source => 'TmpHoldsqueue', value => $val });
|
||||
my $cnt2 = $schema->resultset('TmpHoldsqueue')->count;
|
||||
my $cnt1 = $schema->resultset('AccountCreditTypesBranch')->count;
|
||||
# Insert a new record in AccountCreditTypesBranch with that biblionumber
|
||||
my $rec = $builder->build({ source => 'AccountCreditTypesBranch' });
|
||||
my $cnt2 = $schema->resultset('AccountCreditTypesBranch')->count;
|
||||
is( defined($rec) && $cnt2 == $cnt1 + 1 , 1, 'Created a record' );
|
||||
is( $builder->delete({ source => 'TmpHoldsqueue', records => $rec }),
|
||||
is( $builder->delete({ source => 'AccountCreditTypesBranch', records => $rec }),
|
||||
undef, 'delete returns undef' );
|
||||
is( $rec->{biblionumber}, $bibno, 'Hash value untouched' );
|
||||
is( $schema->resultset('TmpHoldsqueue')->count, $cnt2,
|
||||
is( $schema->resultset('AccountCreditTypesBranch')->count, $cnt2,
|
||||
"Method did not delete record in table without PK" );
|
||||
|
||||
# Test delete with NULL values
|
||||
$val = { branchcode => undef };
|
||||
my $val = { branchcode => undef };
|
||||
is( $builder->delete({ source => 'Branch', records => $val }), 0,
|
||||
'delete returns zero for an undef search with one key' );
|
||||
$val = { module_bit => 1, #catalogue
|
||||
|
|
Loading…
Reference in a new issue