File: helper-webfakes.R

package info (click to toggle)
r-cran-httr2 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,604 kB
  • sloc: sh: 21; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local_app_request <- function(fun, method = "get", frame = parent.frame()) {
  # Works interactively (useful for manaul coverage checking)
  # but not in separate process
  if (!interactive()) {
    skip_on_covr()
  }

  app <- webfakes::new_app()
  app[[method]]("/test", fun)
  server <- webfakes::local_app_process(app, .local_envir = frame)

  req <- request(server$url("/test"))
  req <- req_error(req, body = function(resp) {
    if (resp_has_body(resp)) resp_body_string(resp)
  })
  req
}