https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41901 --- Comment #13 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 197541 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=197541&action=edit Bug 41901: Unit tests Extends the existing `post() tests` subtest in t/db_dependent/api/v1/authorities.t with coverage for the new `x-koha-matchrule` header that selects a Koha record matching rule (`C4::Matcher`, record_type=authority) for duplicate detection when creating authorities via POST /api/v1/authorities. The new cases exercise: * non-integer id (rejected by the OpenAPI schema validator) * unknown matcher id -> 400 `matching_rule_not_found` * biblio matcher id -> 400 `invalid_matching_rule_type` * valid authority matcher returning duplicates -> 409 with a `matches` array of `{authid, score}` objects * valid authority matcher returning no duplicates -> 201 * matcher combined with `x-koha-override: duplicate` -> 201 (override wins, matcher is skipped) `C4::Matcher` is mocked deterministically to avoid relying on the authority search engine in the test database. These tests fail without the controller/spec changes introduced in the follow-up commit. Test plan: 1) Apply only this patch and run `prove t/db_dependent/api/v1/authorities.t`. => Failures are expected in the `post() tests` subtest for the `x-koha-matchrule` cases. 2) Apply the next patch in the series and re-run the tests. => All subtests pass. Signed-off-by: Brian J. Barr <brian.barr@churchofjesuschrist.org> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.