From af8ff8ca0b5adda92f29a6d3b1e10e35d20fb7f1 Mon Sep 17 00:00:00 2001 From: egillax Date: Thu, 30 Jan 2025 16:28:44 +0100 Subject: [PATCH] add teardown again --- tests/testthat/setup.R | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index c9fa01c2..4c479669 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -18,7 +18,7 @@ if (rlang::is_installed("curl")) { internet <- FALSE message("Internet: ", internet) } - + saveLoc <- tempfile("saveLoc") dir.create(saveLoc) @@ -180,3 +180,20 @@ if (internet && rlang::is_installed("Eunomia")) { saveDirectory = file.path(saveLoc, "tinyResults") ) } + +withr::defer( + { + if (Sys.getenv("GITHUB_ACTIONS") == "true") { + # Remove the JDBC driver folder + jarFolder <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER", unset = "") + if (jarFolder != "") { + unlink(jarFolder, recursive = TRUE) + } + } + unlink(saveLoc, recursive = TRUE) + if (internet && rlang::is_installed("Eunomia")) { + unlink(connectionDetails$server()) + } + }, + envir = teardown_env() +)