Skip to content

Commit

Permalink
Assign & test IDs to dataset (fix #47)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinleinweber committed Mar 27, 2018
1 parent 4354a25 commit c30e203
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/retrieve_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ retrieve_data <- function(searchTerm,
taxon_data[i] <- download(paste0(URLs[i], "?format=json"))
}
taxon_data <- lapply(taxon_data, jsonlite::fromJSON)
names(taxon_data) <- IDs
return(taxon_data)

} else if (is.list(x) && length(x) == 1) {
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-retrieve_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ Bac_hal <- "Bacillus halotolerans"
Bac_hal_data <- retrieve_data(searchTerm = Bac_hal,
force_taxon_download = TRUE)

test_that("any dataset returned by BacDiveR is named with its ID", {
expect_equal(retrieve_data(searchTerm = Bac_hal),
as.numeric(names(Bac_hal_data)))
})

test_that("normalising invalid JSON newlines works", {

expect_type(
Expand Down

0 comments on commit c30e203

Please sign in to comment.