diff --git a/tests/testthat/_snaps/write-plumber.md b/tests/testthat/_snaps/write-plumber.md index 31f10f21..0c6901f3 100644 --- a/tests/testthat/_snaps/write-plumber.md +++ b/tests/testthat/_snaps/write-plumber.md @@ -17,6 +17,44 @@ pr %>% vetiver_api(v) } +# create plumber.R for complicated board + + Code + cat(readr::read_lines(tmp), sep = "\n") + Output + # Generated by the vetiver package; edit with care + + library(pins) + library(plumber) + library(rapidoc) + library(vetiver) + b <- board_s3(bucket = "foo", region = 6, endpoint = 8) + v <- vetiver_pin_read(b, "cars1") + + #* @plumber + function(pr) { + pr %>% vetiver_api(v) + } + +# create plumber.R for URL board + + Code + cat(readr::read_lines(tmp), sep = "\n") + Output + # Generated by the vetiver package; edit with care + + library(pins) + library(plumber) + library(rapidoc) + library(vetiver) + b <- board_url(c(foo = "foo", bar = "bar", baz = "baz")) + v <- vetiver_pin_read(b, "cars1") + + #* @plumber + function(pr) { + pr %>% vetiver_api(v) + } + # create plumber.R with packages Code diff --git a/tests/testthat/test-write-plumber.R b/tests/testthat/test-write-plumber.R index 2cd94a58..66841c90 100644 --- a/tests/testthat/test-write-plumber.R +++ b/tests/testthat/test-write-plumber.R @@ -13,6 +13,46 @@ test_that("create plumber.R with no packages", { ) }) +test_that("create plumber.R for complicated board", { + skip_on_cran() + b <- pins::new_board( + "pins_board_s3", + api = 1L, + cache = board_cache_path("pins"), + versioned = FALSE, + bucket = "foo", + svc = list(.internal = + list(config = list(credentials = list(creds = list(profile = 4)), + region = 6, endpoint = 8))) + ) + local_mocked_bindings(vetiver_pin_read = function(board, name, version) v) + tmp <- tempfile() + vetiver_write_plumber(b, "cars1", file = tmp) + expect_snapshot( + cat(readr::read_lines(tmp), sep = "\n"), + transform = redact_vetiver + ) +}) + +test_that("create plumber.R for URL board", { + skip_on_cran() + b <- pins::new_board( + "pins_board_url", + api = 1L, + cache = board_cache_path("pins"), + versioned = FALSE, + bucket = "foo", + urls = c(foo = "foo", bar = "bar", baz = "baz") + ) + local_mocked_bindings(vetiver_pin_read = function(board, name, version) v) + tmp <- tempfile() + vetiver_write_plumber(b, "cars1", file = tmp) + expect_snapshot( + cat(readr::read_lines(tmp), sep = "\n"), + transform = redact_vetiver + ) +}) + test_that("create plumber.R with packages", { skip_on_cran() b <- board_folder(path = tmp_dir)