Skip to content

Commit

Permalink
test: rm explicit namespacing in test
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay committed Aug 16, 2024
1 parent 61c1d66 commit 9aa5c5b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
58 changes: 33 additions & 25 deletions R/create_golem.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,36 @@ replace_package_name <- function(
}
}

copy_golem_skeleton_and_replace_name <- function(
path_to_golem,
package_name
){
cli_cat_rule("Copying package skeleton")
from <- golem_sys("shinyexample")

# Copy over whole directory
fs_dir_copy(
path = from,
new_path = path_to_golem,
overwrite = TRUE
)

# Listing copied files ***from source directory***
copied_files <- list.files(
path = from,
full.names = FALSE,
all.files = TRUE,
recursive = TRUE
)

replace_package_name(
copied_files,
package_name,
path_to_golem
)
cat_green_tick("Copied app skeleton")
}

# For mocking in tests
here_set_here <- function(...){
here::set_here(...)
Expand Down Expand Up @@ -121,33 +151,11 @@ create_golem <- function(
cat_green_tick("Created package directory")
}


cli_cat_rule("Copying package skeleton")
from <- golem_sys("shinyexample")

# Copy over whole directory
fs_dir_copy(
path = from,
new_path = path_to_golem,
overwrite = TRUE
)

# Listing copied files ***from source directory***
copied_files <- list.files(
path = from,
full.names = FALSE,
all.files = TRUE,
recursive = TRUE
)

replace_package_name(
copied_files,
package_name,
path_to_golem
copy_golem_skeleton_and_replace_name(
path_to_golem,
package_name
)

cat_green_tick("Copied app skeleton")

old <- setwd(path_to_golem)

cli_cat_rule("Running project hook function")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ perform_inside_a_new_golem <- function(fun) {
)
)
if (!dir.exists(pkg_reload)) {
golem::create_golem(
create_golem(
pkg_reload,
open = FALSE
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-bundle_resources.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
test_that("multiplication works", {
run_quietly_in_a_dummy_golem({
golem::add_css_file(
add_css_file(
pkg = ".",
"bundle",
open = FALSE
)
golem::add_js_file(
add_js_file(
pkg = ".",
"bundle",
open = FALSE
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-set_golem_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("set_golem_options works", {
golem_wd = ".",
app_prod = FALSE,
talkative = FALSE,
config_file = golem::get_current_config(".")
config_file = get_current_config(".")
)
expect_equal(
get_golem_name(
Expand Down

0 comments on commit 9aa5c5b

Please sign in to comment.