tests/testthat/test-annotation-message.R

test_that("serial message handler works", {
  pa <- api("annotations/serial_message.R")
  pa$test_message(fiery::fake_request("http://127.0.0.1:8080"), FALSE, "hi")
  expect_equal(pa$get_data("message"), "hi")
})

test_that("async message handler works", {
  pa <- api("annotations/async_message.R")
  pa$test_message(
    fiery::fake_request("http://127.0.0.1:8080"),
    FALSE,
    "async hi"
  )
  while (is.null(pa$get_data("async_message"))) {
    later::run_now()
    Sys.sleep(0.01)
  }
  expect_equal(pa$get_data("async_message"), "async hi")
})

Try the plumber2 package in your browser

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

plumber2 documentation built on Jan. 20, 2026, 5:06 p.m.