From 963f7406f0c79122c290aaecb11cdde3b0b43592 Mon Sep 17 00:00:00 2001 From: jgilber2 Date: Sun, 5 Jan 2025 17:46:01 -0800 Subject: [PATCH] refined sweep tests --- tests/testthat/test-parameterSweep.R | 40 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/tests/testthat/test-parameterSweep.R b/tests/testthat/test-parameterSweep.R index a1bc6c1..192ce26 100644 --- a/tests/testthat/test-parameterSweep.R +++ b/tests/testthat/test-parameterSweep.R @@ -27,23 +27,29 @@ testAllParams <- function(connectionDetails, studyStartDate <- "" studyEndDate <- "" } - sccResult <- runSelfControlledCohort(connection = conn, - cdmDatabaseSchema = cdmDatabaseSchema, - cdmVersion = cdmVersion, - exposureIds = c(767410, 1314924, 907879), - exposureTable = exposureTable, - outcomeIds = 444382, - outcomeTable = outcomeTable, - minAge = minAge, - maxAge = maxAge, - studyStartDate = studyStartDate, - studyEndDate = studyEndDate, - addLengthOfExposureExposed = addLengthOfExposure, - addLengthOfExposureUnexposed = addLengthOfExposure, - hasFullTimeAtRisk = hasFullTimeAtRisk, - computeTarDistribution = computeTarDistribution) - expect_equal(class(sccResult), "sccResults") - expect_equal(class(summary(sccResult)), "data.frame") + + resultPath <- tempfile() + dir.create(resultPath) + runSelfControlledCohort(connection = conn, + cdmDatabaseSchema = cdmDatabaseSchema, + cdmVersion = cdmVersion, + exposureIds = c(767410, 1314924, 907879), + exposureTable = exposureTable, + outcomeIds = 444382, + outcomeTable = outcomeTable, + negativeControlPairs = list(c(767410, 444382)), + controlType = "exposure", + minAge = minAge, + maxAge = maxAge, + studyStartDate = studyStartDate, + studyEndDate = studyEndDate, + addLengthOfExposureExposed = addLengthOfExposure, + addLengthOfExposureUnexposed = addLengthOfExposure, + hasFullTimeAtRisk = hasFullTimeAtRisk, + computeTarDistribution = computeTarDistribution, + resultExportPath = resultPath) + + expect_file_exists(file.path(resultPath, "scc_result.csv")) } } }