Skip to content

Add tests for removeBrokenSpeciesListLinks matching on catch fraction, year and country - #285

Closed
rix133 with Copilot wants to merge 2 commits into
mainfrom
copilot/remove-broken-species-list-links-tests
Closed

rix133 with Copilot wants to merge 2 commits into
mainfrom
copilot/remove-broken-species-list-links-tests

Conversation

Copilot AI commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

removeBrokenSpeciesListLinks used to match SS to SL on SLspeclistName only. The function now joins on species list name, catch fraction, year and country. The existing tests didn't exercise that, so a mismatch on any of the new keys could go unnoticed. This PR adds that test coverage and makes no change to the function itself.

Changes

  • Tests only: tests/testthat/test-removeBrokenSpeciesListLinks.R gains four test_that blocks, using the existing h1_v_20250211 fixture:
    • Valid links: no SS rows are removed.
    • No SL rows left: filtering SLspeclistName to a non-existent value ("xxx") removes all SS rows.
    • Catch fraction mismatch: setting SLcatchFrac <- "xxx" removes all SS rows. This is the case the old name-only filter missed.
    • Year and country mismatch: blanking SLyear, then SLcou, each removes all SS rows. The two cases sit in one block, so a failure there won't say which key broke.
myObj[["SL"]]$SLcatchFrac <- "xxx"
res <- removeBrokenSpeciesListLinks(myObj, verbose = FALSE)
expect_equal(nrow(res[["SS"]]), 0)

Review notes

  • The mismatched SLyear and SLcou columns are set with [] <- NA. This keeps the column type, so the dplyr::inner_join doesn't fail on a type mismatch before it gets to the matching.
  • I haven't run the new tests, because R isn't available in my environment. Please run them before merging.

Co-authored-by: rix133 <6965560+rix133@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix removeBrokenSpeciesListLinks filter to include year, catchFraction, and country Add tests for removeBrokenSpeciesListLinks matching on catch fraction, year and country Oct 15, 2026
Copilot AI requested a review from rix133 October 15, 2026 07:43
Copilot AI linked an issue Oct 15, 2026 that may be closed by this pull request
@rix133

rix133 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

ok dont work on main work on dev make a pull request to dev

@rix133 rix133 closed this Oct 15, 2026
@rix133
rix133 deleted the copilot/remove-broken-species-list-links-tests branch October 15, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

removeBrokenSpeciesListLinks filter not working properly

2 participants