Bug 39286

Summary: BackgroundJob.t should mock_config
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to main --- QA Contact: Tomás Cohen Arazi (tcohen) <tomascohen>
Severity: normal    
Priority: P5 - low CC: magnus, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on: 35655    
Bug Blocks: 34070    
Attachments: Bug 39286: Use mock_config instead of env vars
Bug 39286: Use mock_config instead of env vars
Bug 39286: Use mock_config instead of env vars

Description Jonathan Druart 2025-03-10 10:14:03 UTC
Bug 35655 needed to mock the config, but instead introduced new env variables.
Comment 1 Jonathan Druart 2025-03-10 10:17:01 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2025-03-11 09:23:47 UTC
Created attachment 179148 [details] [review]
Bug 39286: Use mock_config instead of env vars

Bug 35655 needed to mock the config, but instead introduced new env variables.

Test plan:
  prove t/db_dependent/Koha/BackgroundJob.t
should still return green

Bonus 1: no more warning
t/db_dependent/Koha/BackgroundJob.t .. 1/6 Cannot connect to broker Failed to connect: Error connecting to not_localhost:99999: Invalid argument at /usr/share/perl5/Net/Stomp.pm line 27.; giving up at /usr/share/perl5/Net/Stomp.pm line 27.

Bonus 2: tests are passing even if you have 'message_broker' in the
config
To test this, add the following entry to $KOHA_CONf then prove again
 <message_broker>
    <hostname>localhost</hostname>
    <port>61613</port>
    <username>guest</username>
    <password>guest</password>
    <vhost></vhost>
 </message_broker>
=> Without this patch the tests fail because the config will overwrite
the env vars.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Warning goes away and prove works even with the message_broker config.
Comment 3 Tomás Cohen Arazi (tcohen) 2025-03-11 12:21:47 UTC
Created attachment 179161 [details] [review]
Bug 39286: Use mock_config instead of env vars

Bug 35655 needed to mock the config, but instead introduced new env variables.

Test plan:
  prove t/db_dependent/Koha/BackgroundJob.t
should still return green

Bonus 1: no more warning
t/db_dependent/Koha/BackgroundJob.t .. 1/6 Cannot connect to broker Failed to connect: Error connecting to not_localhost:99999: Invalid argument at /usr/share/perl5/Net/Stomp.pm line 27.; giving up at /usr/share/perl5/Net/Stomp.pm line 27.

Bonus 2: tests are passing even if you have 'message_broker' in the
config
To test this, add the following entry to $KOHA_CONf then prove again
 <message_broker>
    <hostname>localhost</hostname>
    <port>61613</port>
    <username>guest</username>
    <password>guest</password>
    <vhost></vhost>
 </message_broker>
=> Without this patch the tests fail because the config will overwrite
the env vars.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Warning goes away and prove works even with the message_broker config.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 4 Katrin Fischer 2025-03-17 07:28:46 UTC
Pushed for 25.05!

Well done everyone, thank you!