Skip to content

Commit 381a935

Browse files
author
Your Name
committed
deal with source_folder deprecation
1 parent 429bf35 commit 381a935

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

R/add_dockerfiles_renv.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_dockerfile_with_renv_ <- function(
2828

2929
check_dockerfiler_installed()
3030

31+
3132
if (is.null(lockfile)) {
3233
rlang::check_installed(
3334
c("renv", "attachment"),
@@ -159,7 +160,7 @@ add_dockerfile_with_renv_ <- function(
159160
from =
160161
paste0(
161162
get_golem_name(
162-
pkg = source_folder
163+
golem_wd = golem_wd
163164
),
164165
"_*.tar.gz"
165166
),
@@ -313,7 +314,7 @@ add_dockerfile_with_renv <- function(
313314
}
314315
if (is.null(dockerfile_cmd)) {
315316
dockerfile_cmd <- sprintf(
316-
"R -e \"options('shiny.port'=%s,shiny.host='%s',golem.app.prod=%s);library(%3$s);%3$s::run_app()\"",
317+
"R -e \"options('shiny.port'=%s,shiny.host='%s',golem.app.prod=%s);library(%4$s);%4$s::run_app()\"",
317318
port,
318319
host,
319320
set_golem.app.prod,
@@ -372,15 +373,15 @@ docker run -p %s:%s %s
372373
# then go to 127.0.0.1:%s",
373374
tolower(paste0(
374375
get_golem_name(
375-
pkg = source_folder
376+
golem_wd = golem_wd
376377
),
377378
":latest"
378379
)),
379380
port,
380381
port,
381382
tolower(paste0(
382383
get_golem_name(
383-
pkg = source_folder
384+
golem_wd = golem_wd
384385
),
385386
":latest"
386387
)),

tests/testthat/test-add_dockerfiles_renv.R

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,34 @@ test_that("add_dockerfile_with_renv_ works", {
2222
dockerfile_with_renv <- add_dockerfile_with_renv_(
2323
golem_wd = dummy_golem,
2424
lockfile = "renv.lock.prod",
25-
pkgbuild_quiet = TRUE
25+
pkgbuild_quiet = TRUE,
26+
output_dir=tempfile()
2627
)
2728

2829
dockerfile_with_renv_output <- add_dockerfile_with_renv(
2930
golem_wd = dummy_golem,
3031
lockfile = "renv.lock.prod",
31-
open = FALSE
32+
open = FALSE,
33+
output_dir=tempfile()
34+
)
35+
dockerfile_with_renv_output_dev <- add_dockerfile_with_renv(
36+
set_golem.app.prod = FALSE,
37+
golem_wd = dummy_golem,
38+
lockfile = "renv.lock.prod",
39+
open = FALSE,
40+
output_dir=tempfile()
3241
)
3342
dockerfile_with_renv_shinyproxy_output <- add_dockerfile_with_renv_shinyproxy(
3443
golem_wd = dummy_golem,
3544
lockfile = "renv.lock.prod",
36-
open = FALSE
45+
open = FALSE,
46+
output_dir=tempfile()
3747
)
3848
dockerfile_with_renv_heroku_output <- add_dockerfile_with_renv_heroku(
3949
golem_wd = dummy_golem,
4050
lockfile = "renv.lock.prod",
41-
open = FALSE
51+
open = FALSE,
52+
output_dir=tempfile()
4253
)
4354
}
4455
)
@@ -55,6 +66,40 @@ test_that("add_dockerfile_with_renv_ works", {
5566
dockerfile_with_renv_output
5667
)
5768
)
69+
expect_true(
70+
file.exists(
71+
dockerfile_with_renv_output_dev
72+
)
73+
)
74+
expect_true(
75+
file.exists(
76+
file.path(dirname(dockerfile_with_renv_output),"Dockerfile")
77+
)
78+
)
79+
expect_true(
80+
file.exists(
81+
file.path(dirname(dockerfile_with_renv_output_dev),"Dockerfile")
82+
)
83+
)
84+
85+
dock <- readLines(file.path(dirname(dockerfile_with_renv_output),"Dockerfile"))
86+
87+
expect_true(
88+
any(grepl("library\\(shinyexample\\)",dock))
89+
)
90+
expect_true(
91+
any(grepl("golem.app.prod=TRUE",dock))
92+
)
93+
dock_dev <- readLines(file.path(dirname(dockerfile_with_renv_output_dev),"Dockerfile"))
94+
95+
expect_true(
96+
any(grepl("library\\(shinyexample\\)",dock_dev))
97+
)
98+
expect_true(
99+
any(grepl("golem.app.prod=FALSE",dock_dev))
100+
)
101+
102+
58103
expect_true(
59104
file.exists(
60105
dockerfile_with_renv_shinyproxy_output

0 commit comments

Comments
 (0)