From 4bc868463247525120ca36c54e73718af134d483 Mon Sep 17 00:00:00 2001 From: Jordan Walker Date: Tue, 25 Apr 2017 18:26:09 -0500 Subject: [PATCH] Test for POST issue --- tests/testthat/tests_general.R | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/testthat/tests_general.R b/tests/testthat/tests_general.R index fb864239..c0c2e4ba 100644 --- a/tests/testthat/tests_general.R +++ b/tests/testthat/tests_general.R @@ -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" + ) +})