From 30464bf4ff131d8071722e2d4010569589216a9c Mon Sep 17 00:00:00 2001 From: William Gearty Date: Wed, 23 Oct 2024 16:45:00 -0400 Subject: [PATCH] vcr updates, including docs in CONTRIBUTING.md --- .gitattributes | 2 ++ .github/CONTRIBUTING.md | 17 ----------------- CONTRIBUTING.md | 31 +++++++++++++++++++++++++++++++ DESCRIPTION | 2 +- tests/testthat/test-rl_taxa.R | 2 +- 5 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 .gitattributes delete mode 100644 .github/CONTRIBUTING.md create mode 100644 CONTRIBUTING.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..165ff7a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +tests/fixtures/**/* -diff diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index dc5570e..0000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,17 +0,0 @@ -# CONTRIBUTING # - -### Bugs? - -* Submit an issue on the [Issues page](https://github.com/ropensci/rredlist/issues) - -### Code contributions - -* Fork this repo to your Github account -* Clone your version on your account down to your machine from your account, e.g,. `git clone https://github.com//rredlist.git` -* Make sure to track progress upstream (i.e., on our version of `rredlist` at `ropensci/rredlist`) by doing `git remote add upstream https://github.com/ropensci/rredlist.git`. Before making changes make sure to pull changes in from upstream by doing either `git fetch upstream` then merge later or `git pull upstream` to fetch and merge in one step -* Make your changes (bonus points for making changes on a new feature branch) -* Run tests! -* Push up to your account -* Submit a pull request to home base at `ropensci/rredlist` - -### Also, check out our [discussion forum](https://discuss.ropensci.org) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..81999ba --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# CONTRIBUTING # + +### Bugs? + +* Submit an issue on the [Issues page](https://github.com/ropensci/rredlist/issues) + +### Code contributions + +* Fork this repo to your Github account +* Clone your version on your account down to your machine from your account, e.g,. `git clone https://github.com//rredlist.git` +* Make sure to track progress upstream (i.e., on our version of `rredlist` at `ropensci/rredlist`) by doing `git remote add upstream https://github.com/ropensci/rredlist.git`. Before making changes make sure to pull changes in from upstream by doing either `git fetch upstream` then merge later or `git pull upstream` to fetch and merge in one step +* Make your changes (bonus points for making changes on a new feature branch) +* Run tests! +* Push up to your account +* Submit a pull request to home base at `ropensci/rredlist` + +### Testing + +This package uses [`vcr`](https://docs.ropensci.org/vcr/) on top of [`testthat`](https://testthat.r-lib.org/) for testing: HTTP requests and responses are saved so that when running tests, the cached things ("cassettes") are used instead of repeated calls to web services. + +If you're new to such a testing setup, read [HTTP testing in R](https://books.ropensci.org/http-testing/index.html). + +In practice, it means: + +* **For new tests** you should add `vcr::use_cassette()` around your function calls that use HTTP, or around whole tests. Check out existing test files. Running a new test the first time will create cassettes in `tests/fixtures/` (i.e., YAML files containing HTTP requests and response). Please commit the cassette with your test. + +* If you edit the HTTP request a function or a test is making, delete the corresponding cassette before running the tests. Then commit the changes to the cassette with your changes to the test. + +`rredlist` requires an API key to work. When testing locally, you will need to use your own API key to generate new cassettes. The API key would normally be recorded in HTTP requests and responses. However, we've set it up so that `vcr` filters this sensitive data out of the cassettes. **Make sure to never include your own API key when making changes to the codebase, including tests.** + +### Also, check out our [discussion forum](https://discuss.ropensci.org) diff --git a/DESCRIPTION b/DESCRIPTION index be9070a..96839bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Imports: Suggests: spelling, testthat, - vcr (>= 0.4.0), + vcr (>= 0.6.0), knitr, rmarkdown RoxygenNote: 7.3.2 diff --git a/tests/testthat/test-rl_taxa.R b/tests/testthat/test-rl_taxa.R index e20ec3d..443fcd8 100644 --- a/tests/testthat/test-rl_taxa.R +++ b/tests/testthat/test-rl_taxa.R @@ -69,7 +69,7 @@ for (i in seq_along(ranks)) { expect_named(aajson, c(paste0(rank, "_names"))) expect_is(aajson[[paste0(rank, "_names")]], "character") - vcr::use_cassette(paste0(fn_name, "_"), { + vcr::use_cassette(fn_name_, { aa <- fn_(name, all = FALSE) })