ThinkR-open / mariobox

A Framework For Packaging {plumber} APIs
Other
38 stars 1 forks source link

fix: Issue with ./tests/testthat/test-run_plumber.R #6

Closed ColinFay closed 1 year ago

ColinFay commented 1 year ago

new_api() is from mariobox, not the created API

test_that("new_api() works", {
  api <- new_api()
  expect_s3_class(
    api,
    c("Plumber", "Hookable", "R6")
  )
  # The run() method is available within the object
  expect_equal(
    ls(api, pattern = "^run$"),
    "run"
  )
})

So when we test, this fails.

Suggestion:

run_api <- function() {
  generate_api()$run()
}

generate_api <- function() {
  mariobox::new_api(
    yaml_file = system.file(
      "mariobox.yml",
      package = "ploom"
    )
  )
}

and

test_that("generate_api() works", {
  api <- generate_api()
  expect_s3_class(
    api,
    c("Plumber", "Hookable", "R6")
  )
  # The run() method is available within the object
  expect_equal(
    ls(api, pattern = "^run$"),
    "run"
  )
})
ALanguillaume commented 1 year ago

Solved in #8