Skip to content

Commit

Permalink
Fix bug; extend unit test to cover subset of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed Jan 21, 2025
1 parent a1da50e commit d3eb9be
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/Execution.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ execute <- function(analysisSpecifications,
cat(error(paste0("ERROR: ", message, "\n")))
}

.subsetAnalysisSpecificationByModulesToExecute <- function(analysisSpecification, modulesToExecute) {
.subsetAnalysisSpecificationByModulesToExecute <- function(analysisSpecifications, modulesToExecute) {
# Get the modules in the analysis specification with their
# index in the array
modulesWithIndex <- lapply(
Expand Down
43 changes: 43 additions & 0 deletions tests/testthat/test-Execution.R
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,49 @@ test_that("Specify subset of modules to run", {
)

expect_true(all(modulesExecuted %in% modulesToExecute))

# Create a results DB and upload results
dbFilePath <- file.path(tempDir, "testdm.sqlite")
mydb <- dbConnect(RSQLite::SQLite(), dbFilePath)
dbDisconnect(mydb)

withr::defer(
{
unlink(dbFilePath, recursive = TRUE, force = TRUE)
},
testthat::teardown_env()
)

resultsConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = "sqlite",
server = dbFilePath
)

resultsDataModelSettings <- Strategus::createResultsDataModelSettings(
resultsDatabaseSchema = "main",
resultsFolder = executionSettings$resultsFolder,
modulesToExecute = modulesToExecute
)

# Create cdm modules results data model -------------------------
cdmModulesAnalysisSpecifications <- ParallelLogger::loadSettingsFromJson(
fileName = system.file("testdata/cdmModulesAnalysisSpecifications.json",
package = "Strategus"
)
)

Strategus::createResultDataModel(
analysisSpecifications = cdmModulesAnalysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)

# Upload cdm related results --------------------
Strategus::uploadResults(
analysisSpecifications = analysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)
})

test_that("Stop if error occurs during cohort generation", {
Expand Down

0 comments on commit d3eb9be

Please sign in to comment.