diff --git a/tests/testthat/test-handle.R b/tests/testthat/test-handle.R index 04f4e5f..52bf494 100644 --- a/tests/testthat/test-handle.R +++ b/tests/testthat/test-handle.R @@ -132,7 +132,7 @@ test_that("Custom vector options", { handle_setopt(h, quote = c("bla")) }) -test_that("Custom URL parser", { +test_that("Timeout error includes hostname", { h <- new_handle(timeout = 1L) expect_error(curl_fetch_memory('https://httpbin.org/delay/10', handle = h), 'Timeout was reached: [httpbin.org] ', fixed = TRUE) diff --git a/tests/testthat/test-multi-download.R b/tests/testthat/test-multi-download.R index f7bba29..a779259 100644 --- a/tests/testthat/test-multi-download.R +++ b/tests/testthat/test-multi-download.R @@ -3,7 +3,7 @@ context("Multi download") test_that("Stress test multi_download", { skip_on_cran() mirror <- 'https://cloud.r-project.org' - pkgs <- row.names(available.packages(repos = mirror))[1:3000] + pkgs <- row.names(available.packages(repos = mirror))[1:1000] urls <- sprintf('%s/web/packages/%s/DESCRIPTION', mirror, pkgs) outdir <- file.path(tempdir(), 'descriptions') files <- sprintf('%s/%s.txt', outdir, pkgs) diff --git a/tests/testthat/test-multi.R b/tests/testthat/test-multi.R index 11ad106..cf1ba16 100644 --- a/tests/testthat/test-multi.R +++ b/tests/testthat/test-multi.R @@ -1,8 +1,7 @@ context("Multi handle") test_that("Timeout works", { - skip_on_os("solaris") - h1 <- new_handle(url = httpbin("delay/3")) + h1 <- new_handle(url = httpbin("delay/10")) h2 <- new_handle(url = httpbin("post"), postfields = "bla bla") h3 <- new_handle(url = "https://urldoesnotexist.xyz", connecttimeout = 1) h4 <- new_handle(url = "http://localhost:14", connecttimeout = 1) @@ -13,12 +12,9 @@ test_that("Timeout works", { multi_add(h4, pool = m) rm(h1, h2, h3, h4) gc() - out <- multi_run(timeout = 2, pool = m) - expect_equal(out, list(success = 1, error = 2, pending = 1)) - out <- multi_run(timeout = 0, pool = m) - expect_equal(out, list(success = 0, error = 0, pending = 1)) - out <- multi_run(pool = m) - expect_equal(out, list(success = 1, error = 0, pending = 0)) + spent <- system.time(out <- multi_run(timeout = 2, pool = m)) + expect_lte(out$pending, 2) + expect_lte(spent[['elapsed']], 4) }) test_that("Callbacks work", {