Skip to content

Commit

Permalink
test: skip suggests package if not installed (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay authored Oct 12, 2022
1 parent d53e9f6 commit da97c1a
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 70 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: golem
Title: A Framework for Robust Shiny Applications
Version: 0.3.3.9000
Version: 0.3.4
Authors@R:
c(person(given = "Colin",
family = "Fay",
Expand Down Expand Up @@ -82,11 +82,12 @@ Suggests:
testthat,
tools,
withr,
attachment (>= 0.2.5)
attachment (>= 0.2.5),
renv
VignetteBuilder:
knitr
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.0
RoxygenNote: 7.2.1
10 changes: 5 additions & 5 deletions R/add_dockerfiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,33 @@ talk_once <- function(.f, msg = "") {
#' @examples
#' \donttest{
#' # Add a standard Dockerfile
#' if (interactive()) {
#' if (interactive() & requireNamespace("dockerfiler")) {
#' add_dockerfile()
#' }
#' # Crete a 'deploy' folder containing everything needed to deploy
#' # the golem using docker based on {renv}
#' if (interactive()) {
#' if (interactive() & requireNamespace("dockerfiler")) {
#' add_dockerfile_with_renv(
#' # lockfile = "renv.lock", # uncomment to use existing renv.lock file
#' output_dir = "deploy"
#' )
#' }
#' # Add a Dockerfile for ShinyProxy
#' if (interactive()) {
#' if (interactive() & requireNamespace("dockerfiler")) {
#' add_dockerfile_shinyproxy()
#' }
#'
#' # Crete a 'deploy' folder containing everything needed to deploy
#' # the golem with ShinyProxy using docker based on {renv}
#' if (interactive()) {
#' if (interactive() & requireNamespace("dockerfiler")) {
#' add_dockerfile_with_renv(
#' # lockfile = "renv.lock",# uncomment to use existing renv.lock file
#' output_dir = "deploy"
#' )
#' }
#'
#' # Add a Dockerfile for Heroku
#' if (interactive()) {
#' if (interactive() & requireNamespace("dockerfiler")) {
#' add_dockerfile_heroku()
#' }
#' }
Expand Down
4 changes: 0 additions & 4 deletions R/add_r_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ add_r_files <- function(
}

if (with_test) {
rlang::check_installed(
"usethis",
"to build the test structure."
)
usethis::use_test(
basename(
file_path_sans_ext(
Expand Down
5 changes: 0 additions & 5 deletions R/test_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#' @return A testthat result.
#' @export
#' @rdname testhelpers
#'
#' @examples
#' expect_shinytag(shiny::tags$span("1"))
expect_shinytag <- function(object) {
rlang::check_installed(
"testthat",
Expand All @@ -27,8 +24,6 @@ expect_shinytag <- function(object) {

#' @export
#' @rdname testhelpers
#' @examples
#' expect_shinytaglist(shiny::tagList(1))
expect_shinytaglist <- function(object) {
rlang::check_installed(
"testthat",
Expand Down
42 changes: 21 additions & 21 deletions R/with_opt.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,38 @@ with_golem_options <- function(
#' @return The value of the option.
#'
#' @examples
#' \dontrun{
#'
#' # Define and use golem_options
#' if (interactive()) {
#' # 1. Pass parameters to `run_app`
#'
#' # 1. Pass parameters to `run_app`
#' # to set default value, edit run_app like this :
#'
#' # to set default value, edit run_app like this :
#' run_app <- function(
#' run_app <- function(
#' title = "this",
#' content = "that"
#' ) {
#' with_golem_options(
#' app = shinyApp(
#' ui = app_ui,
#' server = app_server
#' ),
#' golem_opts = list(
#' p1 = p1,
#' p3 = p3
#' ) {
#' with_golem_options(
#' app = shinyApp(
#' ui = app_ui,
#' server = app_server
#' ),
#' golem_opts = list(
#' p1 = p1,
#' p3 = p3
#' )
#' )
#' )
#' }
#' }
#'
#' # 2. Get the values from the UI side
#' # 2. Get the values from the UI side
#'
#' h1(get_golem_options("title"))
#' h1(get_golem_options("title"))
#'
#' # 3. Get the value from the server-side
#' # 3. Get the value from the server-side
#'
#' output$param <- renderPrint({
#' paste("param p2 = ", get_golem_options("p2"))
#' })
#' output$param <- renderPrint({
#' paste("param p2 = ", get_golem_options("p2"))
#' })
#' }
#'
get_golem_options <- function(which = NULL) {
Expand Down
10 changes: 5 additions & 5 deletions man/dockerfiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions man/get_golem_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/testhelpers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion tests/testthat/test-add_deploy_helpers.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
test_that("add_dockerfiles", {
skip_if_not_installed("dockerfiler", "0.1.4")
skip_if_not_installed("renv")
skip_if_not_installed("dockerfiler", "0.2.0")
skip_if_not_installed("attachment", "0.2.5")

with_dir(pkg, {
for (fun in list(
add_dockerfile,
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-extra_sysreqs.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
test_that("test extra sysreqs", {
skip_if_not_installed("renv")
skip_if_not_installed("dockerfiler", "0.2.0")
skip_if_not_installed("attachment", "0.2.5")
with_dir(pkg, {
for (fun in list(
add_dockerfile,
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-renv_stuff.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
test_that("add_dockerfiles_renv and add_dockerfile_with_renv_shinyproxy all output file are present", {
skip_if_not_installed("renv")
skip_if_not_installed("dockerfiler", "0.2.0")

skip_if_not_installed("attachment", "0.2.5")
with_dir(pkg, {
for (fun in list(
add_dockerfile_with_renv,
Expand Down

0 comments on commit da97c1a

Please sign in to comment.