From 887acf7e81c340debaf649e1eb5949dac9ca8e25 Mon Sep 17 00:00:00 2001 From: Jared Knowles Date: Mon, 27 Jul 2026 10:19:55 -0400 Subject: [PATCH] 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. --- tests/testthat/test-expenditure-concept.R | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testthat/test-expenditure-concept.R b/tests/testthat/test-expenditure-concept.R index 1970ebb..2c202ff 100644 --- a/tests/testthat/test-expenditure-concept.R +++ b/tests/testthat/test-expenditure-concept.R @@ -219,6 +219,19 @@ test_that("the refusal message names the fix and the reason", { msg <- paste(conditionMessage(err), collapse = " ") expect_match(msg, "direct") 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", { @@ -226,4 +239,8 @@ test_that("both cross-government verbs still accept the direct default", { cog_geographic_rollup(govids = list(state = "010000226085"), category = "Police", years = 2019) ) + expect_no_error( + cog_peer_compare(target_govid = "010000226085", peers = "010000226085", + category = "Police", years = 2019) + ) })