# Tests for helpful error messages test_that("error messages are informative", { expect_error( fetch_nomis(), "Dataset ID required" ) expect_error( get_codes(), "Dataset ID.*required" ) expect_error( aggregate_geography(data.frame(x = 1), "TYPE", "missing"), "not found" ) }) test_that("missing package errors suggest installation", { # Use skip_if_not_installed (reverse logic) skip_if_not_installed("rsdmx") # If rsdmx IS installed, we can't test the error message # So we skip this test when rsdmx is available skip("rsdmx is installed, cannot test error message") }) # Alternative test that works regardless test_that("missing package errors are handled", { # Test that functions check for required packages # This will pass whether or not rsdmx is installed if (!requireNamespace("rsdmx", quietly = TRUE)) { expect_error( lookup_geography("London"), "rsdmx.*required|install" ) } else { # If rsdmx is installed, just verify function exists expect_true(exists("lookup_geography")) } })