Bug 36493 - Test for GET /api/v1/cash_registers/:cash_register_id/cashups is fragile
Summary: Test for GET /api/v1/cash_registers/:cash_register_id/cashups is fragile
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 26274
Blocks:
  Show dependency treegraph
 
Reported: 2024-04-02 15:36 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2024-05-28 17:54 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.06,23.05.12
Circulation function:


Attachments
Bug 36493: Make cashups test more robust (1.47 KB, patch)
2024-04-02 15:42 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 36493: Make cashups test more robust (1.51 KB, patch)
2024-04-02 17:44 UTC, David Nind
Details | Diff | Splinter Review
Bug 36493: Make cashups test more robust (1.61 KB, patch)
2024-04-12 06:26 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2024-04-02 15:36:55 UTC
This test fails if Koha has a cash register defined already, with ID=1.

To reproduce:
1. Fire up a fresh KTD
2. Add a cash register (needs UseCashRegisters enabled)
3. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/cashups.t
=> FAIL: Expecting a 404 ("Register not found"), getting a 200.
Comment 1 Tomás Cohen Arazi (tcohen) 2024-04-02 15:42:29 UTC
Created attachment 164285 [details] [review]
Bug 36493: Make cashups test more robust

This patch makes the test independent from existing cash registers in
the system.

To test:
1. Enable UseCashRegisters on a fresh KTD
2. Add a cash register
3. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/cashups.t
=> FAIL: Tests fail!
4. Apply this patch
5. Repeat 3
=> SUCCESS: Tests pass!
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 David Nind 2024-04-02 17:44:53 UTC
Created attachment 164288 [details] [review]
Bug 36493: Make cashups test more robust

This patch makes the test independent from existing cash registers in
the system.

To test:
1. Enable UseCashRegisters on a fresh KTD
2. Add a cash register
3. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/cashups.t
=> FAIL: Tests fail!
4. Apply this patch
5. Repeat 3
=> SUCCESS: Tests pass!
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2024-04-02 17:49:39 UTC
Testing notes (using KTD):

1. The first cash register created doesn't always have an ID of 1.

2. I had to update the database manually to have one with an ID of 1:
   - Access the database: koha-mysql kohadev
   - Get a list of cash registers: select * from cash_registers;
   - Update the cash register ID (XXXXX = the name of the cash register from
     the first query): 
      update cash_registers set id=1 where name="XXXXX";
Comment 4 Marcel de Rooy 2024-04-12 06:26:50 UTC
Created attachment 164788 [details] [review]
Bug 36493: Make cashups test more robust

This patch makes the test independent from existing cash registers in
the system.

To test:
1. Enable UseCashRegisters on a fresh KTD
2. Add a cash register
3. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/cashups.t
=> FAIL: Tests fail!
4. Apply this patch
5. Repeat 3
=> SUCCESS: Tests pass!
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Katrin Fischer 2024-04-12 09:28:23 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 6 Fridolin Somers 2024-05-23 12:36:26 UTC
Pushed to 23.11.x for 23.11.06
Comment 7 Lucas Gass (lukeg) 2024-05-28 17:54:21 UTC
Backported to 23.05.x for upcoming 23.05.12