tests/testthat/test-router-modifier.R

context("Router modifier (@plumber tag)")

test_that("router modifier works", {
  pr <- pr(test_path("files/router-modifier.R"))
  expect_equal(class(pr$routes[[1]])[1], "PlumberEndpoint")
  expect_equal(names(pr$routes), "avatartare")
})

test_that("$run() causes error", {
  expect_error(
    pr(test_path("files/router-modifier-run.R")),
    "method should not be called while")
})


test_that("new routers can not be returned", {
  expect_error(
    pr(test_path("files/router-modifier-new.R")),
    "not the same as the one provided")
})

Try the plumber package in your browser

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

plumber documentation built on Sept. 7, 2022, 1:05 a.m.