Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
- Added linter
- Removed mac-arm64
- Missing directory separator in Windows runner
  • Loading branch information
Insang Song committed Feb 7, 2024
1 parent d19a0fa commit 89c0a2f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: macos-13-xlarge, r: 'release'}
#- {os: macos-13-xlarge, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Add this line

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
60 changes: 28 additions & 32 deletions tests/testthat/test-download_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ testthat::test_that("EPA AQS download URLs have HTTP status 200.", {
year_end <- 2022
resolution_temporal <- "daily"
parameter_code <- 88101
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
download_data(dataset_name = "aqs",
year_start = year_start,
Expand Down Expand Up @@ -134,8 +134,8 @@ testthat::test_that("Ecoregion download URLs have HTTP status 200.", {
withr::local_package("httr")
withr::local_package("stringr")
# function parameters
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
certificate <- system.file("extdata/cacert_gaftp_epa.pem",
package = "amadeus")
# run download function
Expand Down Expand Up @@ -179,7 +179,7 @@ testthat::test_that("GEOS-CF download URLs have HTTP status 200.", {
date_end <- "2019-09-21"
collections <- c("aqc_tavg_1hr_g1440x721_v1",
"chm_inst_1hr_g1440x721_p23")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
for (c in seq_along(collections)) {
# run download function
download_data(dataset_name = "geos",
Expand Down Expand Up @@ -221,8 +221,8 @@ testthat::test_that("GMTED download URLs have HTTP status 200.", {
# "Mean Statistic", "Maximum Statistic",
"Standard Deviation Statistic")
resolution <- "7.5 arc-seconds"
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
for (s in seq_along(statistics)) {
# run download function
download_data(dataset_name = "gmted",
Expand Down Expand Up @@ -265,7 +265,7 @@ testthat::test_that("MERRA2 download URLs have HTTP status 200.", {
date_start <- "2022-02-14"
date_end <- "2022-03-08"
collections <- c("inst1_2d_asm_Nx", "inst3_3d_asm_Np")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
for (c in seq_along(collections)) {
# run download function
download_data(dataset_name = "merra2",
Expand Down Expand Up @@ -301,7 +301,7 @@ testthat::test_that("MERRA2 download URLs have HTTP status 200.", {
testthat::test_that("MERRA2 returns message with unrecognized collection.", {
# function parameters
collections <- "uNrEcOgNiZeD"
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
testthat::expect_error(
download_data(
dataset_name = "merra",
Expand All @@ -319,7 +319,7 @@ testthat::test_that("NARR monolevel download URLs have HTTP status 200.", {
year_start <- 2018
year_end <- 2018
variables <- c("weasd", "air.2m")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
download_data(dataset_name = "narr_monolevel",
year_start = year_start,
Expand Down Expand Up @@ -354,7 +354,7 @@ testthat::test_that("NARR p-levels download URLs have HTTP status 200.", {
year_start <- 2020
year_end <- 2021
variables <- c("shum", "omega")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
download_data(dataset_name = "narr_p_levels",
year_start = year_start,
Expand Down Expand Up @@ -388,8 +388,8 @@ testthat::test_that("NOAA HMS Smoke download URLs have HTTP status 200.", {
# function parameters
date_start <- "2022-08-12"
date_end <- "2022-09-21"
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
download_data(dataset_name = "smoke",
date_start = date_start,
Expand Down Expand Up @@ -429,8 +429,8 @@ testthat::test_that("NLCD download URLs have HTTP status 200.", {
years <- c(2021, 2019, 2016)
collections <- c(rep("Coterminous United States", 2), "Alaska")
collection_codes <- c(rep("l48", 2), "ak")
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
for (y in seq_along(years)) {
download_data(dataset_name = "nlcd",
Expand Down Expand Up @@ -487,8 +487,8 @@ testthat::test_that("SEDAC groads download URLs have HTTP status 200.", {
# function parameters
data_regions <- c("Americas", "Global")
data_formats <- c("Geodatabase", "Shapefile")
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
for (r in seq_along(data_regions)) {
data_region <- data_regions[r]
Expand Down Expand Up @@ -548,8 +548,8 @@ testthat::test_that("SEDAC population download URLs have HTTP status 200.", {
data_formats <- c("GeoTIFF")
data_resolutions <- cbind(c("30 second"),
c("30_sec"))
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
for (f in seq_along(data_formats)) {
data_format <- data_formats[f]
for (y in seq_along(years)) {
Expand Down Expand Up @@ -655,8 +655,8 @@ testthat::test_that("Koppen Geiger download URLs have HTTP status 200.", {
# function parameters
time_periods <- c("Present", "Future")
data_resolutions <- c("0.0083")
directory_to_download <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_download <- testthat::test_path("..", "testdata/", "")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
for (p in seq_along(time_periods)) {
time_period <- time_periods[p]
Expand Down Expand Up @@ -709,7 +709,7 @@ testthat::test_that("MODIS-MOD09GA download URLs have HTTP status 200.", {
horizontal_tiles <- c(12, 13)
vertical_tiles <- c(5, 6)
nasa_earth_data_token <- "tOkEnPlAcEhOlDeR"
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
for (y in seq_along(years)) {
date_start <- paste0(years[y], "-06-20")
date_end <- paste0(years[y], "-06-24")
Expand Down Expand Up @@ -763,7 +763,7 @@ testthat::test_that("MODIS-MOD06L2 download URLs have HTTP status 200.", {
nasa_earth_data_token <- "tOkEnPlAcEhOlDeR"
horizontal_tiles <- c(8, 10)
vertical_tiles <- c(4, 5)
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")

testthat::expect_error(
kax <- download_data(dataset_name = "modis",
Expand Down Expand Up @@ -842,7 +842,7 @@ testthat::test_that("MODIS download error cases.", {
horizontal_tiles <- c(12, 13)
vertical_tiles <- c(5, 6)
nasa_earth_data_token <- "tOkEnPlAcEhOlDeR"
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
date_start <- paste0(years, "-06-25")
date_end <- paste0(years, "-06-30")

Expand Down Expand Up @@ -973,7 +973,7 @@ testthat::test_that("EPA TRI download URLs have HTTP status 200.", {
withr::local_package("httr")
withr::local_package("stringr")
# function parameters
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
# run download function
download_data(dataset_name = "tri",
directory_to_save = directory_to_save,
Expand Down Expand Up @@ -1012,7 +1012,7 @@ testthat::test_that("EPA NEI (AADT) download URLs have HTTP status 200.", {
withr::local_package("httr")
withr::local_package("stringr")
# function parameters
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
certificate <- system.file("extdata/cacert_gaftp_epa.pem",
package = "amadeus")
# run download function
Expand Down Expand Up @@ -1056,7 +1056,7 @@ testthat::test_that("Test error cases in EPA gaftp sources 1", {
withr::local_package("stringr")
# function parameters
tdir <- tempdir()
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
certificate <- file.path(tdir, "cacert_gaftp_epa.pem")
# run download function
year_target <- c(2017L)
Expand All @@ -1082,16 +1082,14 @@ testthat::test_that("Test error cases in EPA gaftp sources 1", {
# remove file with commands after test
testthat::expect_true(file.exists(commands_path))
file.remove(commands_path)
file.remove(certificate)
file.remove(sub("pem", "crt", certificate))
})

testthat::test_that("Test error cases in EPA gaftp sources 2", {
withr::local_package("httr")
withr::local_package("stringr")
# function parameters
tdir <- tempdir(check = TRUE)
directory_to_save <- testthat::test_path("..", "testdata/")
directory_to_save <- testthat::test_path("..", "testdata/", "")
certificate <- file.path(tdir, "cacert_gaftp_epa.pem")
# run download function

Expand All @@ -1117,6 +1115,4 @@ testthat::test_that("Test error cases in EPA gaftp sources 2", {
# remove file with commands after test
testthat::expect_true(file.exists(commands_path))
file.remove(commands_path)
file.remove(certificate)
file.remove(sub("pem", "crt", certificate))
})

0 comments on commit 89c0a2f

Please sign in to comment.