From 00dba6ad58e3f6e275454b65dc58906801a85d80 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 26 Apr 2024 15:19:43 +0200 Subject: [PATCH] preserve randomness in table generation --- tests/testthat/test-UploadToDatabase.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-UploadToDatabase.R b/tests/testthat/test-UploadToDatabase.R index 283c5d9ea..0125080f4 100644 --- a/tests/testthat/test-UploadToDatabase.R +++ b/tests/testthat/test-UploadToDatabase.R @@ -31,9 +31,13 @@ connectionRedshift <- DatabaseConnector::createConnectionDetails( conn <- DatabaseConnector::connect(connectionRedshift) targetDialect <- 'postgresql' -randVar <- rawToChar(as.raw(sample(c(65:90,97:122), 5, replace=T))) +withr::with_seed(NULL, { + randVar <- rawToChar(as.raw(sample(c(65:90,97:122), 5, replace=T))) + } +) + appendRandom <- function(x, rand = randVar){ - return(paste("plp_", rand, x, sep='')) + return(paste("plp", rand, x, sep='')) } } @@ -119,7 +123,7 @@ test_that("database creation", { test_that("results uploaded to database", { skip_if(Sys.getenv('CI') != 'true', 'not run locally') - resultsLoc <- file.path(saveLoc,'dbUp') + resultsLoc <- file.path(saveLoc,'dbUp') plpResult$model$trainDetails$developmentDatabase <- 'test' savePlpResult(plpResult, file.path(resultsLoc, 'Analysis_1','plpResult'))