Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/R.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ jobs:

- name: Upload test results
if: failure()
continue-on-error: true
uses: actions/upload-artifact@v5
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
if-no-files-found: ignore
8 changes: 4 additions & 4 deletions R/ebv_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
#'
#' @examples
#'
#' \donttest{
#' #' #get all available datasets
#' \dontrun{
#' # get all available datasets
#' datasets <- ebv_download()
#'
#' ebv_download(id = datasets$id[1], outputdir =
#' tempdir(), overwrite=TRUE,
#' verbose=FALSE)
#' tempdir(), overwrite = TRUE,
#' verbose = FALSE)
#' }
ebv_download <- function(id=NULL,
outputdir,
Expand Down Expand Up @@ -190,6 +190,6 @@

}

return(file.path(outputdir, name_nc))

Check warning on line 193 in R/ebv_download.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_download.R,line=193,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.

Check warning on line 193 in R/ebv_download.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_download.R,line=193,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.

}
8 changes: 4 additions & 4 deletions man/ebv_download.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 52 additions & 49 deletions tests/testthat/test-download.R
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
# basic tests for ebv_download ----
#check url
portal_down <- ebv_i_check_url('https://portal.geobon.org/api/v1/datasets')

if(portal_down){
#expect an error
expect_error(ebv_download(27, dir, verbose = FALSE))
}else{
#run 'normal' tests
test_that("test ebv_download ID=numeric", {
dir <- tempdir()
data <- ebv_download(27, dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
#clean
unlink(dir, recursive=TRUE)
})

test_that("test ebv_download ID=doi", {
dir <- tempdir()
data <- ebv_download('10.25829/f2rdp4', dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
#clean
unlink(dir, recursive=TRUE)
})

test_that("test ebv_download ID=title 1", {
dir <- tempdir()
data <- ebv_download('Local bird diversity (cSAR/BES-SIM)', dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
#clean
unlink(dir, recursive=TRUE)
})

test_that("test ebv_download ID=title 2", {
dir <- tempdir()
data <- ebv_download("Global trends in biodiversity (BES-SIM PREDICTS)", dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
#clean
unlink(dir, recursive=TRUE)
})

test_that("test ebv_download DOIs in download overview table", {
data <- ebv_download(verbose=FALSE)
#check col names
expect_equal(names(data), c("id","title","doi"))
#check a view DOIs
expect_equal(data[data$id==7, 'doi'], '10.25829/f2rdp4')
expect_equal(data[data$id==42, 'doi'], '10.25829/tder31')
expect_equal(data[data$id==28, 'doi'], '10.25829/bk5g87')
})
skip_if_portal_tests_unavailable <- function() {
testthat::skip_on_ci()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid unconditionally skipping portal tests in CI

Because each test_that now calls skip_if_portal_tests_unavailable(), the first statement testthat::skip_on_ci() causes all download tests in this file to be skipped in GitHub Actions (the R.yaml workflow runs tests in a CI environment). This means ebv_download no longer gets any CI verification, so regressions in the package’s core download paths can merge undetected even when the portal is reachable.

Useful? React with 👍 / 👎.

testthat::skip_if_offline()

if (ebv_i_check_url("https://portal.geobon.org/api/v1/datasets")) {
testthat::skip("EBV Data Portal API is not reachable")
}
}

test_that("test ebv_download ID=numeric", {
skip_if_portal_tests_unavailable()

dir <- tempdir()
data <- ebv_download(27, dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
unlink(dir, recursive = TRUE)
})

test_that("test ebv_download ID=doi", {
skip_if_portal_tests_unavailable()

dir <- tempdir()
data <- ebv_download("10.25829/f2rdp4", dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
unlink(dir, recursive = TRUE)
})

test_that("test ebv_download ID=title 1", {
skip_if_portal_tests_unavailable()

dir <- tempdir()
data <- ebv_download("Local bird diversity (cSAR/BES-SIM)", dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
unlink(dir, recursive = TRUE)
})

test_that("test ebv_download ID=title 2", {
skip_if_portal_tests_unavailable()

dir <- tempdir()
data <- ebv_download("Global trends in biodiversity (BES-SIM PREDICTS)", dir, verbose = FALSE)
expect_true(basename(data) %in% list.files(dir))
unlink(dir, recursive = TRUE)
})

test_that("test ebv_download DOIs in download overview table", {
skip_if_portal_tests_unavailable()

data <- ebv_download(verbose = FALSE)
expect_equal(names(data), c("id", "title", "doi"))
expect_equal(data[data$id == 7, "doi"], "10.25829/f2rdp4")
expect_equal(data[data$id == 42, "doi"], "10.25829/tder31")
expect_equal(data[data$id == 28, "doi"], "10.25829/bk5g87")
})


Loading