|
| 1 | +local_clear_http_options <- function(.local_envir = parent.frame()) { |
| 2 | + nms <- c( |
| 3 | + "timeout", |
| 4 | + "connecttimeout", |
| 5 | + "low_speed_time", |
| 6 | + "low_speed_limit", |
| 7 | + "http_version" |
| 8 | + ) |
| 9 | + opts <- c(paste0("pkgcache_", nms), paste0("pkg_http_", nms)) |
| 10 | + withr::local_options( |
| 11 | + structure(vector("list", length(opts)), names = opts), |
| 12 | + .local_envir = .local_envir |
| 13 | + ) |
| 14 | + envs <- c( |
| 15 | + paste0("PKGCACHE_", toupper(nms)), |
| 16 | + paste0("PKG_HTTP_", toupper(nms)) |
| 17 | + ) |
| 18 | + withr::local_envvar( |
| 19 | + structure(rep(NA_character_, length(envs)), names = envs), |
| 20 | + .local_envir = .local_envir |
| 21 | + ) |
| 22 | +} |
| 23 | + |
1 | 24 | test_that("read_etag", { |
2 | 25 | cat("foobar\n", file = tmp <- tempfile()) |
3 | 26 | expect_equal(read_etag(tmp), "foobar") |
@@ -314,6 +337,8 @@ test_that("download_files, no errors", { |
314 | 337 | }) |
315 | 338 |
|
316 | 339 | test_that("set_pkgcache_curl_options", { |
| 340 | + local_clear_http_options() |
| 341 | + |
317 | 342 | # nothing configured: leave the options untouched, no defaults added |
318 | 343 | expect_equal(set_pkgcache_curl_options(list()), list()) |
319 | 344 | expect_equal(set_pkgcache_curl_options(list(foo = "bar")), list(foo = "bar")) |
@@ -362,6 +387,8 @@ test_that("set_pkgcache_curl_options", { |
362 | 387 | }) |
363 | 388 |
|
364 | 389 | test_that("set_pkgcache_curl_options, pkg_http_ fallback", { |
| 390 | + local_clear_http_options() |
| 391 | + |
365 | 392 | # pkg_http_* option is used when nothing with higher priority is set |
366 | 393 | withr::local_options(pkg_http_http_version = 2) |
367 | 394 | expect_equal(set_pkgcache_curl_options(list())$http_version, 2L) |
|
0 commit comments