diff --git a/.github/workflows/R.yaml b/.github/workflows/R.yaml index 5e1fb42..4f0665e 100644 --- a/.github/workflows/R.yaml +++ b/.github/workflows/R.yaml @@ -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 diff --git a/R/ebv_download.R b/R/ebv_download.R index cf9ad57..e3f489d 100644 --- a/R/ebv_download.R +++ b/R/ebv_download.R @@ -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, diff --git a/README.Rmd b/README.Rmd index de97b9b..ec4513d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -67,6 +67,7 @@ install.packages("ebvcube", repos = c("https://b-cubed-eu.r-universe.dev", "http #troubleshooting in case the BioConductor packages are missing #if one of the following packages is not loaded: rhdf5, DelayedArray, HDF5Array install.packages("BiocManager") +BiocManager::install(version = "3.22") BiocManager::install('rhdf5') BiocManager::install('DelayedArray') BiocManager::install('HDF5Array') diff --git a/README.md b/README.md index a83b535..7234b94 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ install.packages("ebvcube", repos = c("https://b-cubed-eu.r-universe.dev", "http #troubleshooting in case the BioConductor packages are missing #if one of the following packages is not loaded: rhdf5, DelayedArray, HDF5Array install.packages("BiocManager") +BiocManager::install(version = "3.22") BiocManager::install('rhdf5') BiocManager::install('DelayedArray') BiocManager::install('HDF5Array') diff --git a/man/ebv_download.Rd b/man/ebv_download.Rd index fb77258..904be9b 100644 --- a/man/ebv_download.Rd +++ b/man/ebv_download.Rd @@ -38,12 +38,12 @@ output directory. } \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) } } diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png index 959f8ef..b8db467 100644 Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index a30ff1a..5eb7fd5 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ diff --git a/man/figures/README-unnamed-chunk-8-1.png b/man/figures/README-unnamed-chunk-8-1.png index 8e6f033..eb276ad 100644 Binary files a/man/figures/README-unnamed-chunk-8-1.png and b/man/figures/README-unnamed-chunk-8-1.png differ diff --git a/tests/testthat/test-download.R b/tests/testthat/test-download.R index 0c6b5d0..13e6d13 100644 --- a/tests/testthat/test-download.R +++ b/tests/testthat/test-download.R @@ -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() + 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") +}) +