tests/testthat/test-plugin.R

test_that("Plugin interface works", {

  app <- App$new()
  plugin <- expect_r6(Plugin$new("hello"), "Plugin")
  expect_error(app$plugin_attach(plugin, bind = TRUE), NA)
  expect_list(app$hello, len = 0L, names = "named")
  expect_r6(app$plugins$hello, "Plugin")
  expect_identical(app$plugins$hello$app, app)

  app <- App$new()
  plugin_requires <- expect_r6(Plugin$new("hi", "Plugin"), "Plugin")
  expect_error(app$plugin_attach(plugin_requires))
  app$plugin_attach(plugin)
  expect_error(app$plugin_attach(plugin_requires), NA)

})
tjpalanca/webtools documentation built on Dec. 23, 2021, 11 a.m.