@@ -66,3 +66,31 @@ test_that("basic 3dhp service requests", {
6666 expect_s3_class(test_data , " sf" )
6767 })
6868})
69+
70+ test_that(" query_usgs_arcrest degrades gracefully when the feature fetch fails" , {
71+
72+ AOI_new <- sf :: st_as_sfc(sf :: st_bbox(c(xmin = - 89.5 , ymin = 43.0 ,
73+ xmax = - 89.4 , ymax = 43.1 ),
74+ crs = " +proj=longlat +datum=WGS84 +no_defs" ))
75+
76+ # fully mocked at the internal-helper level (no fixtures/network) so a
77+ # fresh, never-memoised call signature isn't required
78+ testthat :: local_mocked_bindings(
79+ get_arcrest_service_info = function (... ) list (
80+ url_base = " https://example.com/MapServer/" ,
81+ all_layers = list (layers = list (list (id = 0 , name = " Flowline" ,
82+ type = " Feature Layer" ))),
83+ id = " id3dhp" ),
84+ hgf_json = function (... ) list (objectIds = list (1 , 2 , 3 )),
85+ # simulates the feature-fetch request failing (e.g. an HTTP 504) after
86+ # the objectIds lookup already succeeded
87+ hgf_sf = function (... ) NULL ,
88+ .package = " hydrogeofetch" )
89+
90+ expect_warning(
91+ out <- hydrogeofetch ::: query_usgs_arcrest(
92+ AOI_new , service = " 3DHP_all" , type = " flowline" ),
93+ " features found" )
94+
95+ expect_null(out )
96+ })
0 commit comments