Skip to content

Commit

Permalink
⬆️ use 3rd testthat #57
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Cazelles committed Nov 1, 2021
1 parent df92726 commit 12327b8
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Encoding: UTF-8
RoxygenNote: 7.1.2
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ rcites_checkid <- function(taxon_id) {
# id check
if (!grepl(taxon_id, pattern = "^[0-9]*$")) {
warning("The taxon concept identifier is made of digits only.")
rcites_msg_info("Skipping", paste0(taxon_id, ".\n"))
rcites_msg_info("Skipping '", paste0(taxon_id, "'.\n"))
out <- TRUE
} else out <- FALSE
out
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
}
],
"readme": "https://github.com/ropensci/rcites/blob/master/README.md",
"fileSize": "1721.753KB",
"fileSize": "1721.984KB",
"keywords": [
"cites",
"api-client",
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/_snaps/token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# test token

Code
set_token("hackme")
Message <simpleMessage>
i Authentication token stored for the session.

6 changes: 2 additions & 4 deletions tests/testthat/test-distributions.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Distributions")

lang_GQ <- c("Equatorial Guinea", "Guinée équatoriale", "Guinea Ecuatorial")

test_that("spp_distributions() defaults work", {
Expand All @@ -10,7 +8,7 @@ test_that("spp_distributions() defaults work", {
expect_type(res[1L], "list")
expect_true(all(unlist(lapply(res, function(x) is_cl_df(x)))))
expect_identical(lang_GQ %in% res$distributions$name, c(TRUE, FALSE, FALSE))
# expect_null(print(res))
# expect_snapshot(print(res))
})

test_that("spp_distributions() raw mode works", {
Expand All @@ -24,7 +22,7 @@ test_that("spp_distributions() raw mode works", {
res2$error$message,
"We are sorry but an error occurred processing your request"
)
# expect_null(print(res))
# expect_snapshot(print(res))
})

test_that("spp_distributions() language works", {
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-legislations.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
context("Legislation")

nm_ci <- c("cites_listings", "cites_quotas", "cites_suspensions")
m_ci <- c("cites_listings", "cites_quotas", "cites_suspensions")
nm_eu <- c("eu_listings", "eu_decisions")

test_that("spp_cites_legislation() defaults work", {
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-pkghelpers.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Helper functions")

# rcites_taxonconcept_request(tx_nm, "CITES", FALSE, 1, 500, NULL, NULL)

## General helpers
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-references.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("References")

nm1 <- c("id", "citation", "is_standard")

test_that("spp_references() defaults works", {
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-taxonconcept.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Taxon concept")

nm1 <- c("all_id", "general", "higher_taxa", "accepted_names", "common_names",
"synonyms", "cites_listings")
nm2 <- c("id", "full_name", "author_year", "rank", "name_status", "updated_at",
Expand Down
10 changes: 7 additions & 3 deletions tests/testthat/test-wrongtoken.R → tests/testthat/test-token.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
context("Wrong token")


token <- "wrong"
msg <- "Unauthorized (HTTP 401)"
q_url <- rcites_url(paste0("taxon_concepts/", tx_id, "/distributions.json"))


test_that("test token", {
old <- Sys.getenv("SPECIESPLUS_TOKEN")
suppressMessages(on.exit(set_token(old)))
expect_snapshot(set_token("hackme"))
expect_identical(Sys.getenv("SPECIESPLUS_TOKEN"), "hackme")
})

test_that("caught wrong token", {
vcr::use_cassette("wrong_token", {
expect_warning(res <- rcites_res(q_url, token, FALSE, TRUE),
Expand Down

0 comments on commit 12327b8

Please sign in to comment.