R/test-helpers.R

Defines functions make_req pr_path

pr_path <- function() system.file("plumber/stringutils/plumber.R", package = "plumbertableau")

make_req <- function(verb = "GET", path = "/", qs="", body="", args = c(), pr = NULL, ...){
  req <- as.environment(list(...))
  req$REQUEST_METHOD <- toupper(verb)
  req$PATH_INFO <- path
  req$QUERY_STRING <- qs

  if (is.character(body)) {
    body <- charToRaw(body)
  }
  stopifnot(is.raw(body))
  req$rook.input <- list(read_lines = function(){ rawToChar(body) },
                         read = function(){ body },
                         rewind = function(){ length(body) })
  req$bodyRaw <- body
  req$pr <- pr
  req
}

Try the plumbertableau package in your browser

Any scripts or data that you put into this service are public.

plumbertableau documentation built on Aug. 6, 2021, 9:05 a.m.