Skip to content

Commit

Permalink
use safer file paths in generate_author_yml() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbarth committed Sep 27, 2023
1 parent 52c73ac commit bd1aa4a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/testthat/test-generate_author_yml.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,28 @@ test_that(

rmd <- paste(rmd, collapse = "\n")

input_path <- tempfile(fileext = ".Rmd")
write(rmd, file = input_path)
input_file <- tempfile(fileext = ".Rmd")
write(rmd, file = input_file)

output_path <- tempfile(fileext = ".pdf")
output_file <- gsub(input_file, pattern = "\\.Rmd$", replacement = ".pdf")

suppressWarnings(
try(
capture.output(
rmarkdown::render(
input = input_path,
output_file = output_path,
quiet = TRUE,
input = input_file,
quiet = TRUE
)
)
, silent = TRUE
)
)

expect_true(file.exists(output_path))
expect_true(file.exists(output_file))

# Clean up
file.remove(input_path)
file.remove(output_path)
file.remove(input_file)
file.remove(output_file)

}
)
Expand Down

0 comments on commit bd1aa4a

Please sign in to comment.