Skip to content

Commit

Permalink
Merge pull request #15 from mrc-ide/refactor-api-test
Browse files Browse the repository at this point in the history
Use entire api object in API tests.
  • Loading branch information
plietar authored Jan 15, 2025
2 parents 6287f46 + 3ad0824 commit 42b295d
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 163 deletions.
33 changes: 15 additions & 18 deletions tests/testthat/helper-orderly-runner.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
orderly_runner_endpoint <- function(
method, path,
root = NULL,
repositories = NULL,
validate = TRUE,
skip_queue_creation = FALSE
) {
if (skip_queue_creation) {
queue <- NULL
} else {
queue <- Queue$new(root)
create_api <- function(root = NULL,
repositories = NULL,
log_level = "off",
...,
env = parent.frame()) {
if (is.null(repositories)) {
repositories <- withr::local_tempdir(.local_envir = env)
}
porcelain::porcelain_package_endpoint(
"orderly.runner", method, path,
state = list(root = root,
repositories_base_path = repositories,
queue = queue),
validate = validate
)

api(root, repositories, validate = TRUE, log_level = log_level, ...)
}


expect_success <- function(res) {
expect_equal(res$status, 200)
invisible(jsonlite::fromJSON(res$body)$data)
}


Expand Down
Loading

0 comments on commit 42b295d

Please sign in to comment.