From e067a5930ffb4eefbf5aaa1bafb5ef14e5e454f7 Mon Sep 17 00:00:00 2001 From: Jared Knowles Date: Tue, 4 Aug 2026 12:07:59 -0400 Subject: [PATCH] test: accept schema_version 7, and keep the upper bound enforced The merged schema-v7 fix (b59b79b) widened .validate_schema()'s allow-list but left this test asserting that 7 is REJECTED, so main went red. CI had been hanging on the apt step before ever reaching the suite, which is why the failure only surfaced once the HTTPS fix let the job get that far. Flips 7L from expect_error to expect_silent, and ADDS an 8L rejection case. That second part is the point: simply deleting the 7L expectation would have left the test unable to prove any upper bound is enforced at all, so a future v8 corpus with a genuinely breaking change would pass validation silently. The test should assert the boundary moved, not that it disappeared. Suite: 796 PASS, 0 FAIL, 0 WARN, 0 SKIP. --- tests/testthat/test-manifest.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-manifest.R b/tests/testthat/test-manifest.R index 318f5a3..31c9462 100644 --- a/tests/testthat/test-manifest.R +++ b/tests/testthat/test-manifest.R @@ -111,7 +111,7 @@ test_that("cog_manifest returns the active session's parsed manifest", { }) }) -test_that(".validate_schema accepts schema_version 4, 5 and 6, rejects others", { +test_that(".validate_schema accepts schema_version 4 through 7, rejects others", { expect_silent(uscogdata:::.validate_schema(list(schema_version = 4L))) expect_silent(uscogdata:::.validate_schema(list(schema_version = 5L))) # v6 = FIPS geography harmonization (2026-07-22): _code -> _asof rename + @@ -119,12 +119,22 @@ test_that(".validate_schema accepts schema_version 4, 5 and 6, rejects others", # renamed columns and its geography comes from the xwalk, so v6 is accepted # without behavioural change -- see .validate_schema()'s note. expect_silent(uscogdata:::.validate_schema(list(schema_version = 6L))) + # v7 = `data_year` APPENDED as column 29 (cog_pipeline #80, 2026-08-03), the + # most recent fiscal year contributing to a collapsed key. Appended, never + # inserted: canonical_govid stays at position 26, so nothing this package + # reads shifts. Verified against the real v7 corpus before widening the + # allow-list -- cog_spending()/cog_balances() return correctly for FY2024 AND + # for FY2012, so the new column is inert here. + expect_silent(uscogdata:::.validate_schema(list(schema_version = 7L))) expect_error( uscogdata:::.validate_schema(list(schema_version = 3L)), "schema_version" ) + # The upper bound still has to be ENFORCED, not just moved. Without this the + # test would no longer prove that an unknown future schema is refused, and a + # v8 corpus with a genuinely breaking change would sail through. expect_error( - uscogdata:::.validate_schema(list(schema_version = 7L)), + uscogdata:::.validate_schema(list(schema_version = 8L)), "schema_version" ) })