Debian Codegraph @

tests/testthat/test-errors.R

raw
1 test_that("test error classes", {
2 # Throw an actual error
3 expect_error(curl::curl_fetch_memory("https://urldoesnotexist.xyz"), class = 'curl_error_couldnt_resolve_host')
4
5 # This handle raises an error
6 error1 <- NULL
7 error2 <- NULL
8 pool <- new_pool()
9 curl::curl_fetch_multi("https://urldoesnotexist.xyz", fail = function(err){
10 error1 <<- err
11 }, pool = pool)
12 curl::curl_fetch_multi("https://urldoesnotexist.xyz", fail = function(){
13 error2 <<- TRUE
14 }, pool = pool)
15 curl::curl_fetch_multi("https://urldoesnotexist.xyz", pool = pool)
16 out <- multi_run(pool = pool)
17 expect_equal(out$error, 3)
18 expect_s3_class(error1, 'curl_error_couldnt_resolve_host')
19 expect_true(error2)
20 })