tests/testthat/test_failing.R

# Usage Guidelines --------------------------------------------------------

sample_upc <- c('889532638123', '889532677788')
sample_store <- c('3301','3254')

# Test Failure ------------------------------------------------------------

# No API Key
testthat::expect_error(
  callInvAPI(upc = sample_upc, store_num = sample_store, api_key = NULL)
)

# You can't search by radius around a store number - must be a postal code
testthat::expect_error(
  callInvAPI(upc = sample_upc, store_num = sample_store, search_radius = '5000',  api_key = Sys.getenv('IBM_API_KEY'))
)

# A failed API call
testthat::expect_error(
  callInvAPI(upc = sample_upc, store_num = sample_store, api_key = 'a_bad_key')
)

# An empty product
testthat::expect_length(
  callInvAPI(upc = '123456789', store_num = sample_store, api_key = Sys.getenv('IBM_API_KEY')), 1L
)
dwernersexton/rPOS documentation built on May 21, 2019, 6:49 a.m.