tests/testthat/test_env.R

context("Test get_env")

test_that("Functions fail when env variables are not set.", {

  sid <- Sys.getenv("TWILIO_SID")
  Sys.setenv(TWILIO_SID = "")
  expect_error(tw_send_message("2125557634", "9178675903", "Hello from R!"))
  Sys.setenv(TWILIO_SID = sid)

  token <- Sys.getenv("TWILIO_TOKEN")
  Sys.setenv(TWILIO_TOKEN = "")
  expect_error(tw_send_message("2125557634", "9178675903", "Hello from R!"))
  Sys.setenv(TWILIO_TOKEN = token)

})

Try the twilio package in your browser

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

twilio documentation built on May 2, 2019, 10:58 a.m.