From 56be9fb75697ec6064e9ace045b94bb419b1ecd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98topepo=E2=80=99?= <‘mxkuhn@gmail.com’> Date: Tue, 16 Apr 2024 09:32:47 -0400 Subject: [PATCH] use test fixtures --- tests/testthat/test-new-blog-post.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-new-blog-post.R b/tests/testthat/test-new-blog-post.R index f3f9744..72204f3 100644 --- a/tests/testthat/test-new-blog-post.R +++ b/tests/testthat/test-new-blog-post.R @@ -1,10 +1,18 @@ test_that("Create a blog post", { skip_if_no_quarto("1.4") - tempdir <- withr::local_tempdir() - withr::local_dir(tempdir) + current_dir <- getwd() + + temp_dir <- withr::local_tempdir() + dir_path <- fs::path(temp_dir, "test-blog-project") + + withr::defer(fs::dir_delete(dir_path), envir = rlang::current_env()) + quarto_create_project(name = "test-blog-project", type = "blog", - dir = tempdir(), quiet = TRUE) + dir = temp_dir, quiet = TRUE) + + setwd(dir_path) + withr::defer(setwd(current_dir), envir = rlang::current_env()) # ------------------------------------------------------------------------------ @@ -38,6 +46,7 @@ test_that("Create a blog post", { "Intro to Felt Surrogacy", dest = "The Science of Illusion", author = "Annie Edison", + date = '2024-04-12', categories = c("shenanigans", "security"), open = FALSE)