Skip to content

Commit 523b923

Browse files
use tempfiles for plots (#5199)
* use tempfiles for plots * need .png extension * use with_tempfile()
1 parent f540d58 commit 523b923

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/testthat/test-ggsave.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ test_that("ggsave can handle blank background", {
5959
})
6060

6161
test_that("ggsave warns about empty or multiple filenames", {
62-
filenames <- c("plot1.png", "plot2.png")
6362
plot <- ggplot(mtcars, aes(disp, mpg)) + geom_point()
6463

65-
withr::with_file(filenames, {
64+
withr::with_tempfile(c("file1", "file2"), fileext = ".png", {
6665
expect_warning(
67-
suppressMessages(ggsave(filenames, plot)),
66+
suppressMessages(ggsave(c(file1, file2), plot)),
6867
"`filename` must have length 1"
6968
)
70-
expect_error(
71-
ggsave(character(), plot),
72-
"`filename` cannot be empty."
73-
)
7469
})
70+
71+
expect_error(
72+
ggsave(character(), plot),
73+
"`filename` cannot be empty."
74+
)
7575
})
7676

7777
# plot_dim ---------------------------------------------------------------

0 commit comments

Comments
 (0)