Permalink
Browse files

Try to fix unit tests

  • Loading branch information...
1 parent 52a4bd0 commit f885cdbd37e4361ec0f8de679223636e8ea68030 @jeroen committed Mar 23, 2017
Showing with 7 additions and 6 deletions.
  1. +2 −2 tests/testthat/test-certificates.R
  2. +2 −2 tests/testthat/test-cookies.R
  3. +3 −2 tests/testthat/test-post.R
@@ -1,8 +1,8 @@
context("Certificate validation")
test_that("Invalid domain raises an error", {
- expect_is(curl_fetch_memory(httpbin("get"))$status, "integer")
- fake_url <- paste0("https://", nslookup("httpbin.org"), "/get")
+ expect_is(curl_fetch_memory("https://www.r-project.org")$status, "integer")
+ fake_url <- paste0("https://", nslookup("www.r-project.org"))
expect_error(curl_fetch_memory(fake_url), "certificate")
expect_is(curl_fetch_memory(fake_url, handle = new_handle(ssl_verifyhost = FALSE))$status, "integer")
})
@@ -13,8 +13,8 @@ test_that("Add some cookies", {
cookies <- handle_cookies(h);
expect_is(cookies, "data.frame")
expect_equal(nrow(cookies), 2)
- expect_equal(cookies$name, c("foo","bar"))
- expect_equal(cookies$value, c("123","ftw"))
+ expect_equal(sort(cookies$name), c("bar", "foo"))
+ expect_equal(sort(cookies$value), c("123","ftw"))
expect_true(all(cookies$expiration == Inf))
})
@@ -17,8 +17,9 @@ test_that("Post text data", {
expect_equal(res$headers$`User-Agent`, "A cow")
# Using connection interface
- txt <- readLines(curl(httpbin("post"), handle = h))
- expect_equal(rawToChar(req$content), paste0(txt, "\n", collapse=""))
+ input <- jsonlite::fromJSON(rawToChar(req$content))
+ output <- jsonlite::fromJSON(curl(httpbin("post"), handle = h))
+ expect_equal(input, output)
# Using download interface
tmp <- tempfile()

0 comments on commit f885cdb

Please sign in to comment.