From 8f60e2ba1e5f35ed403541d215803d6d6dae2bfd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 19 Oct 2021 10:34:38 +0000 Subject: [PATCH] Bug 25030: (QA follow-up) Fix tests Fluid is not a valid value for cxn_pool - valid values are: Sniff,Static,NoPing AddAuthority call calls index - the indexing call was trying to access the ES server with mocked values and dying when they were invalid This patch uses a correct value for cxn_pool and inserts directly into DB to avoid indexing --- t/db_dependent/Koha/SearchEngine/Elasticsearch.t | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t index 53a236a49d..78d0c4e331 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -29,7 +29,7 @@ use MARC::Record; use Try::Tiny; use List::Util qw( any ); -use C4::AuthoritiesMarc; +use C4::AuthoritiesMarc qw( AddAuthority ); use Koha::SearchEngine::Elasticsearch; use Koha::SearchEngine::Elasticsearch::Search; @@ -98,16 +98,16 @@ subtest '_read_configuration() tests' => sub { is( $configuration->{cxn_pool}, 'Static', 'cxn_pool configuration set correctly to Static if not specified' ); is_deeply( $configuration->{nodes}, \@servers , 'Server configuration parsed correctly' ); - t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Fluid' } ); + t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Sniff' } ); $configuration = Koha::SearchEngine::Elasticsearch::_read_configuration; - is( $configuration->{cxn_pool}, 'Fluid', 'cxn_pool configuration parsed correctly' ); + is( $configuration->{cxn_pool}, 'Sniff', 'cxn_pool configuration parsed correctly' ); isnt( defined $configuration->{trace_to}, 'trace_to is not defined if not set' ); my $params = Koha::SearchEngine::Elasticsearch::get_elasticsearch_params; is_deeply( $configuration->{nodes}, \@servers , 'get_elasticsearch_params is just a wrapper for _read_configuration' ); - t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Fluid', trace_to => 'Stderr' } ); + t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Sniff', trace_to => 'Stderr' } ); $configuration = Koha::SearchEngine::Elasticsearch::_read_configuration; is( $configuration->{trace_to}, 'Stderr', 'trace_to configuration parsed correctly' ); @@ -858,6 +858,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents with Inclu t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); t::lib::Mocks::mock_preference('IncludeSeeFromInSearches', '1'); + my $dbh = C4::Context->dbh; my $builder = t::lib::TestBuilder->new; my $auth_type = $builder->build_object({ @@ -871,7 +872,8 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents with Inclu MARC::Field->new(150, '', '', a => 'Foo'), MARC::Field->new(450, '', '', a => 'Bar'), ); - my $authid = AddAuthority($authority_record, undef, $auth_type->authtypecode); + $dbh->do( "INSERT INTO auth_header (datecreated,marcxml) values (NOW(),?)", undef, ($authority_record->as_xml_record('MARC21') ) ); + my $authid = $dbh->last_insert_id( undef, undef, 'auth_header', 'authid' ); my @mappings = ( { -- 2.20.1