tests/testthat/test-5-vignette.R

test_that("pesky troublemaker", {
  skip_on_cran() # because API key...

  results <- gmapsdistance(origin = c("Washington DC", "New York NY",
                                      "Seattle WA", "Miami FL"),
                           destination = c("Los Angeles CA", "Austin TX",
                                           "Chicago IL", "Philadelphia PA"),
                           mode = "bicycling",
                           dep_date = "2023-11-14",
                           dep_time = "23:13:20",
                           key = Sys.getenv("GOOGLE_API_KEY"))

  expect_equal(unique(as.vector(results$Status)), "OK")
  expect_equal(any(is.na(as.vector(results$Time))), FALSE)


  results <- gmapsdistance(origin = c("Washington DC", "New York NY",
                                      "Seattle WA", "Miami FL"),
                           destination = c("Los Angeles CA", "Austin TX",
                                           "Chicago IL", "Philadelphia PA"),
                           mode = "bicycling",
                           # departure time as seconds from Unix Epoch (1970-01-01)
                           # check that it happens in future: as.POSIXct(1700000000, origin="1970-01-01")
                           departure = 1700000000,
                           key = Sys.getenv("GOOGLE_API_KEY"))

  expect_equal(unique(as.vector(results$Status)), "OK")
  expect_equal(any(is.na(as.vector(results$Time))), FALSE)

})

Try the gmapsdistance package in your browser

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

gmapsdistance documentation built on Aug. 10, 2023, 9:06 a.m.