Repository navigation
Add unit tests for v0.40.0 surface (lnk_mapping_code, persist additions, pipeline_run mapping_code phase, deprecation shims) #191
Copy link
Copy link
Open
Description
Context
v0.40.0 (#187) landed substantial new R code without dedicated unit tests. Compile-time checks + /code-check rounds caught real bugs during implementation (Phase 2's conditional-col dropouts, Phase 4's missing roxygen, Phase 6's body-ref renames after signature rename), and the existing 1119-test suite continued to pass — but no new test files / test_that blocks were added for the new surface.
Coverage gaps
| Surface | Current state | Gap |
|---|---|---|
R/lnk_mapping_code.R (new exported function) |
no test file | tests/testthat/test-lnk_mapping_code.R missing entirely |
R/lnk_persist_init.R — new cols_streams_access_base / cols_streams_mapping_code_base + per-species helpers + CREATE TABLE / VIEW blocks |
existing 10 tests cover the pre-#187 schema | no test asserts the new tables/view exist post-init, no test asserts per-species column naming |
R/lnk_pipeline_persist.R — new streams_access + streams_mapping_code write blocks (gated on working-table presence) |
existing 6 tests cover pre-#187 writes | no test asserts the gated-write logic (skip when working table absent; fire + JOIN-back when present) |
R/lnk_pipeline_run.R — new mapping_code = FALSE param + conditional phase |
existing 8 tests cover pre-#187 flow | no test asserts the new phase fires + writes expected tables when mapping_code = TRUE |
R/lnk_pipeline_mapping_code.R — species_<role> param rename + deprecation shims |
existing tests use old param names | no test asserts the deprecation shim warns + remaps correctly |
Goals
Add the missing tests with mocks (same with_mocked_bindings pattern as test-lnk_compare_wsg.R) so:
-
tests/testthat/test-lnk_mapping_code.R— covers query construction (table_*args), habitat long→wide pivot, presence derivation logic,species_<role>pass-through tolnk_pipeline_mapping_code, error paths (empty access, empty habitat). -
test-lnk_persist_init.Rextended — assert<schema>.streams_access,<schema>.streams_mapping_code, and<schema>.streams_habitat_long_vwexist after init with the species-driven column set. Assert per-species column naming convention. -
test-lnk_pipeline_persist.Rextended — assert new write blocks skip cleanly when working tables absent (gating); assert they fire with correct JOIN projection when present. -
test-lnk_pipeline_run.Rextended — assertmapping_code = TRUEtriggers the new phase (mocklnk_barriers_views+lnk_pipeline_access+lnk_mapping_codeand verify call ordering); assertmapping_code = FALSE(default) does not. -
test-lnk_pipeline_mapping_code.Rextended — assert deprecation shims forresident_species/anadromous_species/spawn_only_speciesemit.Deprecated()warning and remap tospecies_<role>.
Acceptance
devtools::test()count increases by 15–25 test_that blocks across the five files (rough estimate based on the surface size).- All new tests use mocks; none require a live DB.
- Deprecation-shim tests verify both warn-on-use and functional-remap.
- 0 FAIL throughout.
References
R/lnk_mapping_code.R— new function, no test file.R/lnk_persist_init.Rlines 60–115 (new cols + helpers) + 232–263 (new CREATE TABLE / VIEW).R/lnk_pipeline_persist.Rlines 104–172 (new write blocks).R/lnk_pipeline_run.Rlines 138–190 (new mapping_code phase).R/lnk_pipeline_mapping_code.Rlines 95–122 (deprecation shims).- Follows from mapping_code build decoupled from tunnel — persist streams_access + lnk_pipeline_run phase + rename with_mapping_code → mapping_code #187 — landed without these tests; this issue tracks the catch-up.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity