Skip to content

Commit

Permalink
Added result tests for refitPsForEveryOutcome
Browse files Browse the repository at this point in the history
  • Loading branch information
mvankessel-EMC committed Sep 1, 2023
1 parent f0b6258 commit 6772089
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/testthat/test-runCmAnalyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,50 @@ test_that("refitPsForEveryOutcome", {
# Throws Error:
# cannot open file '.\Temp\RtmpwLKCGK\cmData6dbc562227db': it is a directory

### Check files ----
refitTrue <- suppressWarnings(runCmAnalyses(
connectionDetails = connectionDetails,
cdmDatabaseSchema = "main",
exposureTable = "cohort",
outcomeTable = "cohort",
outputFolder = outputFolder,
cmAnalysisList = cmAnalysisList,
targetComparatorOutcomesList = targetComparatorOutcomesList,
refitPsForEveryOutcome = TRUE
))

refitFalse <- suppressWarnings(runCmAnalyses(
connectionDetails = connectionDetails,
cdmDatabaseSchema = "main",
exposureTable = "cohort",
outcomeTable = "cohort",
outputFolder = outputFolder,
cmAnalysisList = cmAnalysisList,
targetComparatorOutcomesList = targetComparatorOutcomesList,
refitPsForEveryOutcome = FALSE
))

expect_false(identical(refitTrue, refitFalse))
expect_true(all(grepl(
pattern = "(^StudyPop_l1_s\\d+_t\\d+_c\\d+_o\\d+\\.rds$|^$)",
x = c(refitTrue$studyPopFile, refitFalse$studyPopFile)
)))

expect_true(all(grepl(
pattern = "(^Ps_l1_s\\d+_p\\d+_t\\d+_c\\d+\\.rds$|^$)",
x = c(refitTrue$sharedPsFile, refitFalse$sharedPsFile)
)))

expect_true(all(grepl(
pattern = "(^Ps_l1_s\\d+_p\\d+_t\\d+_c\\d+_o\\d+\\.rds$|^$)",
x = c(refitTrue$psFile, refitFalse$psFile)
)))

expect_true(all(grepl(
pattern = "(^Balance_l1_s\\d+_p\\d+_t\\d+_c\\d+_s\\d+_b\\d+\\.rds$|^$)",
x = c(refitTrue$sharedBalanceFile, refitFalse$sharedBalanceFile)
)))

### 0 ----
unlink(outputFolder, recursive = TRUE)
expect_error(
Expand Down

0 comments on commit 6772089

Please sign in to comment.