test: add missing cog_peer_compare coverage to expenditure_concept tests

- 'both cross-government verbs still accept the direct default' now tests both verbs
- 'the refusal message names the fix and the reason' now asserts both functions name
  themselves correctly in their error messages (cog_geographic_rollup vs cog_peer_compare)

Addresses coordinator feedback to prevent test coverage gaps and ensure the helper's
verb name argument is pinned correctly.
This commit is contained in:
2026-07-27 10:19:55 -04:00
parent 81fd1a5279
commit 887acf7e81
+17
View File
@@ -219,6 +219,19 @@ test_that("the refusal message names the fix and the reason", {
msg <- paste(conditionMessage(err), collapse = " ") msg <- paste(conditionMessage(err), collapse = " ")
expect_match(msg, "direct") expect_match(msg, "direct")
expect_match(msg, "double-count|double count") expect_match(msg, "double-count|double count")
expect_match(msg, "cog_geographic_rollup")
# Test that cog_peer_compare's message names its own function
err2 <- tryCatch(
cog_peer_compare(target_govid = "010000226085", peers = "010000226085",
category = "Police", years = 2019,
expenditure_concept = "total"),
condition = function(e) e
)
msg2 <- paste(conditionMessage(err2), collapse = " ")
expect_match(msg2, "direct")
expect_match(msg2, "double-count|double count")
expect_match(msg2, "cog_peer_compare")
}) })
test_that("both cross-government verbs still accept the direct default", { test_that("both cross-government verbs still accept the direct default", {
@@ -226,4 +239,8 @@ test_that("both cross-government verbs still accept the direct default", {
cog_geographic_rollup(govids = list(state = "010000226085"), cog_geographic_rollup(govids = list(state = "010000226085"),
category = "Police", years = 2019) category = "Police", years = 2019)
) )
expect_no_error(
cog_peer_compare(target_govid = "010000226085", peers = "010000226085",
category = "Police", years = 2019)
)
}) })