tests/testthat/test-callback.R

context("Callback")

test_that("request callback", {
  f <- function(req) req$url
  old <- set_callback("request", f)
  on.exit(set_callback("request", old))

  expect_identical(GET("foo.bar"), "foo.bar")

  expect_identical(f, get_callback("request"))
  expect_identical(f, set_callback("request", old))
  expect_identical(old, get_callback("request"))
})
hadley/httr documentation built on Nov. 4, 2023, 3:17 a.m.