Skip to content

Commit

Permalink
Dev 1059 (#1082)
Browse files Browse the repository at this point in the history
* Fix 1058, 1060, 1062 and improve code coverage in `use_files.R` from 0 to 100% (#1059)

* tests: add dummy files for use_{external,internal}_XXX_files() testing

- add some dummy files to the inst/utils/ directory

- for later: add tests that download exactly from that directory

Refs: #1058

* tests: add testing for external-funcs standard cases

* tests: add testing for internal-funcs standard cases

- fix typo in testfile_template_html
- use styler::style_file(..., style = grkstyle::grk_style_transformer)

* fix: set default value for argument name before using it

- the order needs a change at some places: first set a default value when name argument is missing
    - only then call check_name_length() to avoid errors of the type:
    "argument "name" is missing, with no default"
- also, to avoid RStudio and other IDEs linting a missing argument, provide a default value "NULL" for argument  'name'

Refs: #1060

* feat: improve error handling and allow codecovr. to be 100%

- instead of throwing an error, return 'FALSE' is passed and cat_dir_necessary() prints an informative message to the user (with the same effect i.e. not creating a directory)
- this behavior is a bit more userfriendly and also allows for a code coverage of 100%; the latter is not possible to implement since tests are run non-interactively

* tests: add corner cases for tests to make covr. 100%

* chore bump coverage

---------

Co-authored-by: Ilya Zarubin <[email protected]>
  • Loading branch information
VincentGuyader and ilyaZar authored Aug 8, 2023
1 parent ebcfe13 commit 7ba820b
Show file tree
Hide file tree
Showing 13 changed files with 572 additions and 80 deletions.
16 changes: 8 additions & 8 deletions R/add_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ add_js_file <- function(
msg = "`name` is required"
)

check_name_length(name)
check_name_length_is_one(name)

name <- file_path_sans_ext(name)

Expand Down Expand Up @@ -112,7 +112,7 @@ add_js_handler <- function(
msg = "`name` is required"
)

check_name_length(name)
check_name_length_is_one(name)

name <- file_path_sans_ext(name)

Expand Down Expand Up @@ -177,7 +177,7 @@ add_js_input_binding <- function(
msg = "`name` is required"
)

check_name_length(name)
check_name_length_is_one(name)

attempt::stop_if(
length(events$name) == 0,
Expand Down Expand Up @@ -319,7 +319,7 @@ add_js_output_binding <- function(
msg = "`name` is required"
)

check_name_length(name)
check_name_length_is_one(name)

raw_name <- name

Expand Down Expand Up @@ -403,7 +403,7 @@ add_css_file <- function(
msg = "`name` is required"
)

check_name_length(name)
check_name_length_is_one(name)

name <- file_path_sans_ext(name)

Expand Down Expand Up @@ -465,7 +465,7 @@ add_sass_file <- function(
msg = "`name` is required"
)

check_name_length(name)
check_name_length_is_one(name)

name <- file_path_sans_ext(name)

Expand Down Expand Up @@ -532,7 +532,7 @@ add_html_template <- function(
) {
name <- file_path_sans_ext(name)

check_name_length(name)
check_name_length_is_one(name)

old <- setwd(fs_path_abs(pkg))
on.exit(setwd(old))
Expand Down Expand Up @@ -601,7 +601,7 @@ add_partial_html_template <- function(
dir_create = TRUE
) {
name <- file_path_sans_ext(name)
check_name_length(name)
check_name_length_is_one(name)

old <- setwd(fs_path_abs(pkg))
on.exit(setwd(old))
Expand Down
2 changes: 1 addition & 1 deletion R/add_r_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_r_files <- function(
) {
name <- file_path_sans_ext(name)

check_name_length(name)
check_name_length_is_one(name)

old <- setwd(fs_path_abs(pkg))
on.exit(setwd(old))
Expand Down
2 changes: 1 addition & 1 deletion R/modules_fn.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ add_module <- function(
...
) {
# Let's start with the checks for the validity of the name
check_name_length(name)
check_name_length_is_one(name)
check_name_syntax(name)

# We now check that:
Expand Down
Loading

0 comments on commit 7ba820b

Please sign in to comment.