Closed llrs closed 3 years ago
I'm a little confused here. What does "writing to the database" mean? The database is local on your computer? Or there's a database behind the API referenced?
Most likely the answer is to use webmockr
, but will wait for more details
Sorry :sweat: to write to a remote computer on the database behind the API referenced. The API given the right authentication allows to write/use POST
to insert new records to the database behind it.
Okay, thanks.
If you can write once to the API that accepts a POST request inside of a use_cassette code block, then you can from there on use that cassette created on that one call.
If you don't even want to one real request then you could construct a cassette from scratch - there's not really tools to do that in vcr, but you could just copy/paste then edit another cassette.
Or webmockr is an option - in which you could match on the http request - but don't allow any real request - and you can set the body to be returned (json, list, whatever)
Great! I didn't know how to proceed from the book. Will report back there. One again thanks! In this case the API is R bugzilla, so I would rather avoid sending a mock issue. Will see how I manage copying/building a cassette.
okay, hope something works out well
I come this other issue https://github.com/ropensci-books/http-testing/issues/84.
I would like to test that writing using the API works. So far I tested retrieving data from the API (of the R bug tracker), bu obviously I don't want to write superfluous issues as it is "on production".
What would be the best way to test it using vcr, but without writing to the database?
Session Info
```r ? Session info ???????????????????????????????????????????????????????????????????????? setting value version R version 4.0.1 (2020-06-06) os Ubuntu 20.04.2 LTS system x86_64, linux-gnu ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Madrid date 2021-02-14 ? Packages ???????????????????????????????????????????????????????????????????????????? ! package * version date lib source assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.1) backports 1.2.1 2020-12-09 [1] CRAN (R 4.0.1) base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.0.1) BiocManager * 1.30.10 2019-11-16 [1] CRAN (R 4.0.1) R bugRzilla * 0.0.90001