Skip to content

Commit

Permalink
Merge pull request #9 from R-ArcGIS/empty-res
Browse files Browse the repository at this point in the history
Return NULL when no results are returned
  • Loading branch information
JosiahParry authored Oct 29, 2024
2 parents 9095d29 + 0b6547c commit 7466881
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: arcpbf
Title: Process ArcGIS Protocol Buffer FeatureCollections
Version: 0.1.6
Version: 0.1.6.9000
Authors@R:
person("Josiah", "Parry", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9910-865X"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# arcpbf (development version)

* Fixes bug where an error occured when a query returned no rows <https://github.com/R-ArcGIS/arcpbf/issues/8>

# arcpbf 0.1.6

* Adds `tests/` to `.Rbuildignore` to pass CRAN checks
Expand Down
1 change: 1 addition & 0 deletions R/resp-body-pbf.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ resp_body_pbf <- function(resp, post_process = TRUE, use_sf = TRUE) {
#' @rdname httr2
resps_data_pbf <- function(resps, post_process = TRUE, use_sf = TRUE) {
res <- multi_resp_process_(resps)
if (rlang::is_empty(res)) return(NULL)
if (post_process) {
post_process_pbf(res, use_sf)
} else {
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

# library(testthat)
# library(arcpbf)
library(testthat)
library(arcpbf)

# test_check("arcpbf")
test_check("arcpbf")
16 changes: 16 additions & 0 deletions tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ test_that("dates and ints are returned", {
res <- arc_select(cities_fl, n_max = 10)
expect_true(is.numeric(res$POP_CLASS))
})

test_that("empty queries return null", {
skip_on_cran()
skip_if_not_installed("arcgislayers")
library(arcgislayers)
layer <- arc_open(
"https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized_Boundaries/FeatureServer/0"
)

res <- arc_select(
layer,
where = "STATE_NAME LIKE 'Marylnd'"
)

expect_null(res)
})

0 comments on commit 7466881

Please sign in to comment.