ropensci / vcr

Record HTTP calls and replay them
https://docs.ropensci.org/vcr
Other
77 stars 12 forks source link

how to deal with dates #84

Open sckott opened 5 years ago

sckott commented 5 years ago

e.g.,

vcr::use_cassette("foobar", {
  a_date <- format(Sys.Date() - 1, "%Y-%m-%dT%H:%M:%S+00:00")
  aa <- wm_records_date(a_date)
  expect_is(aa, "data.frame")
})

works fine on the date its run, but then e.g., the next day it's run the date generated in Sys.Date() will be the next day, and then vcr will error and complain that the request doesn't match the fixture in foobar.

https://github.com/vcr/vcr/issues/154 either 1) before_record/before_playback hooks or 2) custom request matcher

sckott commented 5 years ago

working on this in this pkg https://github.com/ropenscilabs/timefuzz

maelle commented 3 years ago

that's interesting, what's the status on this?

sckott commented 3 years ago

timefuzz and clock are still in development - working for the most part BUT the problem is that monkey patching in R is not allowed, so to be able to mock time you'd have to import, or at least suggest, clock and maybe timefuzz too - some may not want to add additional imports just to mock time, but some will

maelle commented 3 years ago

Yeah I suppose that depending on the requests a package makes, mocking time might be crucial!