feat: default to the public corpus so the package works unconfigured
The default was a REPLACE_WITH_SHARE_TOKEN sentinel and no document in the package supplied a working URL, so a new user installing uscogdata had no path to a session at all -- just an actionable-looking error with nothing actionable behind it. The default is now the public HuggingFace mirror: CC-BY-4.0, no credential, CDN-backed, and it keeps the origin's uplink out of the read path. USCOGDATA_URL and options(uscogdata.url=) still override, so Nextcloud and cog_mirror() copies are unaffected. The sentinel guard stays for half-edited configs; the two tests covering it set the URL explicitly, so they only needed renaming to stop calling it 'the default'.
This commit is contained in:
@@ -64,3 +64,26 @@ test_that(".resolve_url does not invent a slash for an empty setting", {
|
||||
withr::local_options(uscogdata.url = "")
|
||||
expect_equal(.resolve_url(), "")
|
||||
})
|
||||
|
||||
test_that("the default corpus URL is real, not a placeholder", {
|
||||
# setup.R points USCOGDATA_URL at the bundled fixture for the whole suite,
|
||||
# so both the env var and the option have to be cleared to see the default.
|
||||
withr::local_envvar(USCOGDATA_URL = NA)
|
||||
withr::local_options(uscogdata.url = NULL)
|
||||
url <- .resolve_url()
|
||||
expect_false(grepl("REPLACE_WITH", url, fixed = TRUE))
|
||||
expect_match(url, "^https://")
|
||||
expect_match(url, "/$")
|
||||
})
|
||||
|
||||
test_that("an explicitly-set sentinel URL still aborts", {
|
||||
# The guard must survive the default change: a user who half-edited a
|
||||
# copied config still gets the actionable error.
|
||||
withr::local_envvar(
|
||||
USCOGDATA_URL = "https://other.example/s/REPLACE_WITH_SHARE_TOKEN/x/"
|
||||
)
|
||||
expect_error(
|
||||
.check_url_configured(.resolve_url()),
|
||||
class = "uscogdata_url_not_configured"
|
||||
)
|
||||
})
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
# protect users from silent failures when USCOGDATA_URL is misconfigured
|
||||
# or returns non-JSON content.
|
||||
|
||||
test_that("cog_open aborts with actionable error when URL is the placeholder default", {
|
||||
test_that("cog_open aborts with actionable error when URL contains the sentinel", {
|
||||
uscogdata:::cog_close()
|
||||
on.exit(uscogdata:::cog_close(), add = TRUE)
|
||||
|
||||
placeholder <- "https://cloud.civilytics.org/s/REPLACE_WITH_SHARE_TOKEN/download/"
|
||||
withr::with_envvar(c(USCOGDATA_URL = placeholder), {
|
||||
# No longer the package default (that is the public HF corpus). This is a
|
||||
# user who copied a config template and did not finish editing it.
|
||||
sentinel_url <- "https://cloud.civilytics.org/s/REPLACE_WITH_SHARE_TOKEN/download/"
|
||||
withr::with_envvar(c(USCOGDATA_URL = sentinel_url), {
|
||||
expect_error(
|
||||
uscogdata:::cog_open(),
|
||||
class = "uscogdata_url_not_configured"
|
||||
@@ -35,8 +37,10 @@ test_that("placeholder guard error names both env var and option as remediation"
|
||||
uscogdata:::cog_close()
|
||||
on.exit(uscogdata:::cog_close(), add = TRUE)
|
||||
|
||||
placeholder <- "https://cloud.civilytics.org/s/REPLACE_WITH_SHARE_TOKEN/download/"
|
||||
withr::with_envvar(c(USCOGDATA_URL = placeholder), {
|
||||
# No longer the package default (that is the public HF corpus). This is a
|
||||
# user who copied a config template and did not finish editing it.
|
||||
sentinel_url <- "https://cloud.civilytics.org/s/REPLACE_WITH_SHARE_TOKEN/download/"
|
||||
withr::with_envvar(c(USCOGDATA_URL = sentinel_url), {
|
||||
msg <- tryCatch(uscogdata:::cog_open(), error = conditionMessage)
|
||||
expect_match(msg, "USCOGDATA_URL", fixed = TRUE)
|
||||
expect_match(msg, "uscogdata.url", fixed = TRUE)
|
||||
|
||||
Reference in New Issue
Block a user