Skip to content

Commit

Permalink
include namespace on geojson_sf call in tests
Browse files Browse the repository at this point in the history
Pass a non valid geojson value to the serializer.
  • Loading branch information
JosiahParry committed Sep 23, 2021
1 parent 5e93cd9 commit d880abf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/testthat/test-parse-body.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ test_that("Test geojson parser", {
# Test sf object w/ fields
geojson <- '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"a":3},"geometry":{"type":"Point","coordinates":[1,2]}},{"type":"Feature","properties":{"a":4},"geometry":{"type":"Point","coordinates":[3,4]}}]}'
parsed <- parse_body(geojson, "application/geo+json", make_parser("geojson"))
expect_equal(parsed, geojson_sf(geojson))
expect_equal(parsed, geojsonsf::geojson_sf(geojson))

# Test sfc
geojson <- '[
{ "type":"Point","coordinates":[0,0]},
{"type":"LineString","coordinates":[[0,0],[1,1]]}
]'
parsed <- parse_body(geojson, "application/geo+json", make_parser("geojson"))
expect_equal(parsed, geojson_sf(geojson))
expect_equal(parsed, geojsonsf::geojson_sf(geojson))

# Test simple sf object
geojson <- '{ "type" : "Point", "coordinates" : [0, 0] }'
parsed <- parse_body(geojson, "application/geo+json", make_parser("geojson"))
expect_equal(parsed, geojson_sf(geojson))
expect_equal(parsed, geojsonsf::geojson_sf(geojson))

# Test geojson file
tmp <- tempfile()
Expand All @@ -140,7 +140,7 @@ test_that("Test geojson parser", {
writeLines(geojson, tmp)
val <- readBin(tmp, "raw", 1000)
parsed <- parse_body(val, "application/geo+json", make_parser("geojson"))
expect_equal(parsed, geojson_sf(geojson))
expect_equal(parsed, geojsonsf::geojson_sf(geojson))

})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-serializer-geojson.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ test_that("Errors call error handler", {
}

expect_equal(errors, 0)
serializer_geojson()(parse(text="hi"), data.frame(), PlumberResponse$new("csv"), errorHandler = errHandler)
serializer_geojson()(parse(text="h$534i} {!"), data.frame(), PlumberResponse$new(), errorHandler = errHandler)
expect_equal(errors, 1)
})

0 comments on commit d880abf

Please sign in to comment.