Skip to content

Commit c2d7887

Browse files
committed
test: handle test warnings due to deprecation
We shouldn't rely on deprecated API in our tests (other than to possibly return deprecation warnings).
1 parent 5ee4b33 commit c2d7887

1 file changed

Lines changed: 7 additions & 24 deletions

File tree

tests/testthat/test-queries.R

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,39 +1372,22 @@ test_that("getter and districts branches are covered", {
13721372
)
13731373
expect_setequal(spouses(cg_admg, index = 2), c("A", "C"))
13741374

1375+
# Test that deprecated 'all' parameter shows warning
13751376
expect_warning(
13761377
districts(cg_admg, all = TRUE),
13771378
"deprecated"
13781379
)
1379-
expect_error(
1380-
districts(cg_admg, all = "x"),
1381-
"`all` must be TRUE, FALSE, or NULL."
1382-
)
1383-
expect_error(
1384-
districts(cg_admg, all = TRUE, nodes = "A"),
1385-
"`all = TRUE` cannot be combined with `nodes` or `index`."
1386-
)
1387-
expect_error(
1388-
districts(cg_admg, all = FALSE),
1389-
"`all = FALSE` requires `nodes` or `index` to be supplied."
1390-
)
1380+
1381+
# Test error for invalid index
13911382
expect_error(
13921383
districts(cg_admg, index = c(1, NA)),
13931384
"`index` must be numeric without NA."
13941385
)
13951386

1396-
all_null <- districts(cg_admg, all = NULL)
1397-
expect_true(is.list(all_null))
1398-
expect_true(length(all_null) >= 1L)
1399-
1400-
all_flag <- structure(FALSE, class = "foo")
1401-
expect_warning(
1402-
expect_error(
1403-
districts(cg_admg, all = all_flag),
1404-
"Supply one of `nodes` or `index`, or set `all = TRUE`."
1405-
),
1406-
"deprecated"
1407-
)
1387+
# Test getting all districts (new API - no parameters)
1388+
all_districts <- districts(cg_admg)
1389+
expect_true(is.list(all_districts))
1390+
expect_true(length(all_districts) >= 1L)
14081391
})
14091392

14101393
test_that("is_mag class short-circuit branch is covered", {

0 commit comments

Comments
 (0)