tests/testthat/test_utils.R

context("utils")

# skip tests because they take too much time
testthat::skip_on_cran()




# ### download metadata ----------------
#
# testthat::test_that("gracefully fail if could not download metadata", {
#
#   # meta data
#   testthat::local_mocked_bindings(
#     check_connection = function(...) { FALSE }
#   )
#   testthat::expect_null( download_metadata() )
# })
#


### check connection ----------------
# url <- 'https://www.google.com:81/'   # timeout
# url <- 'https://httpbin.org/status/300' # error

testthat::test_that("check connection", {

  # timeout
  testthat::expect_false( check_connection(url = 'https://www.google.com:81/') )

  # connection error
  testthat::expect_false( check_connection(url = 'https://httpbin.org/status/300') )

  # check_downloaded_obj
  testthat::expect_null( check_downloaded_obj(NULL) )
  testthat::expect_message( check_downloaded_obj(NULL) )

})

Try the aopdata package in your browser

Any scripts or data that you put into this service are public.

aopdata documentation built on April 4, 2025, 2:01 a.m.