Skip to content

Commit

Permalink
Merge pull request #362 from jiwalker-usgs/master
Browse files Browse the repository at this point in the history
Test for POST issue
  • Loading branch information
ldecicco-USGS committed Apr 26, 2017
2 parents 9941f06 + 4bc8684 commit 66b800a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/tests_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,31 @@ test_that("NGWMN functions working", {
expect_equal(attr(tzDataMT$dateTime, 'tzone'), "US/Mountain")
expect_warning(tzDataUTC$dateTime == tzDataMT$dateTime)
})

context("getWebServiceData")
test_that("long urls use POST", {
url <- paste0(rep("reallylongurl", 200), collapse = '')
with_mock(
RETRY = function(method, ...) {
return(method == "POST")
},
status_code = function(resp) 200,
headers = function(resp) list(`content-type` = "logical"),
content = function(resp, encoding) resp,
expect_true(getWebServiceData(url)),
.env = "httr"
)
})
test_that("ngwmn urls don't use post", {
url <- paste0(rep("urlwithngwmn", 200), collapse = '')
with_mock(
RETRY = function(method, ...) {
return(method == "POST")
},
status_code = function(resp) 200,
headers = function(resp) list(`content-type` = "logical"),
content = function(resp, encoding) resp,
expect_false(getWebServiceData(url)),
.env = "httr"
)
})

0 comments on commit 66b800a

Please sign in to comment.