tests/testthat/test-resource_data_items.R

testthat::test_that('function correctly parses response', {
  
  load(testthat::test_path("test_data", "test_res_success.rda"))
  
  mockery::stub(resource_data_items, 'httr::RETRY', function(...) test_res_success)
  
  testthat::expect_equal(
  digest::digest(resource_data_items(resource="abcdef")),
  "4df5446e9c60b589f88528350c23e4bd"
  )
})

testthat::test_that('function correctly provides error response', {
  
  load(testthat::test_path("test_data", "test_res_fail.rda"))
  
  mockery::stub(resource_data_items, 'httr::RETRY', function(...) test_res_fail)
  
  testthat::expect_error(resource_data_items(resource="abcdef"))
  
})

testthat::test_that('function returns a data.frame from live query', {
  
  testthat::skip_on_cran()
  
  testthat::expect_true(is.data.frame(
    resource_data_items(resource="edee9731-daf7-4e0d-b525-e4c1469b8f69")
    ))
})

testthat::test_that('function returns an error from live query with badly
                    formed resource id', {
  
  testthat::skip_on_cran()
  
  testthat::expect_error(resource_data_items(resource="abcd123"))
})

Try the odns package in your browser

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

odns documentation built on Nov. 10, 2022, 5:56 p.m.