Bug 39700

Summary: Fix test case t/db_dependent/Authority/Merge.t broken in 34739
Product: Koha Reporter: Thomas Klausner <domm>
Component: Test SuiteAssignee: Chris Cormack <chris>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on: 34739    
Bug Blocks:    
Attachments: Bug 39700: Fix test case t/db_dependent/Authority/Merge.t broken in 34739
Bug 39700: Fix test case t/db_dependent/Authority/Merge.t broken in 34739

Description Thomas Klausner 2025-04-22 19:23:10 UTC
Bug 34739 adds some new tests to t/db_dependent/Authority/Merge.t, which work when run alone. But when running the whole test suite, some weird fails show up.

This patch fixes that bug in the test suite


The new test case calls AddBiblio. And AddBiblio returns ($biblionumber, $biblioitemnumber). But the test calls it like this: my $biblionumber = AddBiblio;


AddBiblio returns a list, but the calling code only stores a single value, so it get's the last value, i.e. the biblioitemnumber.


Now, when running the test alone, the DB sequences for biblio and biblioitem are in sync and both return the same value so the test works (by accident)


But some tests add biblios with multiple items (or biblios without items), thus the sequences are no longer in sync and when the test tries to load a biblio via a biblioitemid, it finds nothing, which causes the fail


bad: my $biblionumber = AddBiblio( $biblio_record, '', { skip_record_index => 1 } );

ok-ish: my ($biblionumber) = AddBiblio( $biblio_record, '', { skip_record_index => 1 } );
Comment 1 Thomas Klausner 2025-04-22 19:32:56 UTC
Created attachment 181309 [details] [review]
Bug 39700: Fix test case t/db_dependent/Authority/Merge.t broken in 34739

Bug 34739 added some test cases to t/db_dependent/Authority/Merge.t which work when run as a standlone test, but fail when run with some other tests. This patch fixes the test.

Test Plan:

* Start KTD and enter a shell
* Run only the single test:
  prove t/db_dependent/Authority/Merge.t
* You should get "All test successful"
* Now run two tests:
  prove t/db_dependent/Biblio.t t/db_dependent/Authority/Merge.t
* You will get a FAIL:
  t/db_dependent/Authority/Merge.t (Wstat: 256 (exited 1) Tests: 14 Failed: 1)
  Failed test:  13

* Apply the patch

* Again run two tests:
  prove t/db_dependent/Biblio.t t/db_dependent/Authority/Merge.t
* You should get "All test successful"

Sponsored by: HKS3
Comment 2 Roman Dolny 2025-04-22 20:09:51 UTC
Created attachment 181310 [details] [review]
Bug 39700: Fix test case t/db_dependent/Authority/Merge.t broken in 34739

Bug 34739 added some test cases to t/db_dependent/Authority/Merge.t which work when run as a standlone test, but fail when run with some other tests. This patch fixes the test.

Test Plan:

* Start KTD and enter a shell
* Run only the single test:
  prove t/db_dependent/Authority/Merge.t
* You should get "All test successful"
* Now run two tests:
  prove t/db_dependent/Biblio.t t/db_dependent/Authority/Merge.t
* You will get a FAIL:
  t/db_dependent/Authority/Merge.t (Wstat: 256 (exited 1) Tests: 14 Failed: 1)
  Failed test:  13

* Apply the patch

* Again run two tests:
  prove t/db_dependent/Biblio.t t/db_dependent/Authority/Merge.t
* You should get "All test successful"

Sponsored by: HKS3

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 3 Katrin Fischer 2025-04-23 05:00:18 UTC
Great detective work, thanks a lot, Thomas!
Comment 4 Katrin Fischer 2025-04-23 05:12:42 UTC
Picking this out of the queue :)
Comment 5 Katrin Fischer 2025-04-23 07:43:31 UTC
Pushed for 25.05!

Well done everyone, thank you!