From eaf18bebd3158746f53a5c6ab7d8ee631c2c59df Mon Sep 17 00:00:00 2001 From: Felipe Date: Tue, 9 May 2023 14:57:35 +0000 Subject: [PATCH 1/2] update code style --- R/items-funs.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/R/items-funs.R b/R/items-funs.R index acba1efc..749b5b6b 100644 --- a/R/items-funs.R +++ b/R/items-funs.R @@ -355,8 +355,9 @@ items_next.STACItemCollection <- function(items, ...) { matched <- items_matched(items) q <- doc_query(items) - if (is.null(q)) + if (is.null(q)) { .error("Cannot get next link URL", class = "next_error") + } # get url of the next page next_url <- Filter(function(x) x$rel == "next", items$links) @@ -420,7 +421,6 @@ items_next.STACItemCollection <- function(items, ...) { content <- post_request(next_stac, ..., encode = q$encode) } else { - .error("Invalid HTTP method.") } @@ -430,7 +430,6 @@ items_next.STACItemCollection <- function(items, ...) { # check pagination length if (!is.null(q$params[["limit"]]) && items_length(content) > as.numeric(q$params[["limit"]])) { - .error("STAC invalid retrieved page length.") } @@ -438,7 +437,6 @@ items_next.STACItemCollection <- function(items, ...) { if (!is.null(matched) && !is.null(q$params[["limit"]]) && (items_length(content) != as.numeric(q$params[["limit"]])) && (items_length(content) + items_length(items) != matched)) { - .error("STAC pagination error.") } From d6bf2a4dc2e036d87473b7852865e8c2ed9df80b Mon Sep 17 00:00:00 2001 From: Felipe Date: Tue, 9 May 2023 14:58:07 +0000 Subject: [PATCH 2/2] update test --- tests/testthat/test-signatures.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-signatures.R b/tests/testthat/test-signatures.R index 902fa250..58f46d77 100644 --- a/tests/testthat/test-signatures.R +++ b/tests/testthat/test-signatures.R @@ -94,6 +94,14 @@ testthat::test_that("signature functions", { class = c("STACItemCollection", "RSTACDocument") ) + # provided wrong url + testthat::expect_error( + object = suppressWarnings( + items_sign(stac_items, + sign_fn = sign_planetary_computer(token_url = "test")) + ) + ) + # return the same object after signature? testthat::expect_s3_class( object = suppressWarnings( @@ -123,12 +131,4 @@ testthat::test_that("signature functions", { object = href_item, regexp = "se" ) - - # provided wrong url - testthat::expect_error( - object = suppressWarnings( - items_sign(stac_items, - sign_fn = sign_planetary_computer(token_url = "test")) - ) - ) })