Skip to content

Commit

Permalink
test for cdm_source warning
Browse files Browse the repository at this point in the history
  • Loading branch information
katy-sadowski committed Nov 4, 2023
1 parent 5684275 commit 16990b4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/testthat/test-executeDqChecks.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,30 @@ test_that("Incremental insert SQL is valid.", {

DatabaseConnector::renderTranslateExecuteSql(connection, "DROP TABLE @database_schema.dqd_results;", database_schema = resultsDatabaseSchemaEunomia)
})

test_that("Multiple cdm_source rows triggers warning.", {
outputFolder <- tempfile("dqd_")
on.exit(unlink(outputFolder, recursive = TRUE))

connectionDetailsEunomiaCS <- Eunomia::getEunomiaConnectionDetails()
connection <- DatabaseConnector::connect(connectionDetailsEunomiaCS)
on.exit(DatabaseConnector::disconnect(connection), add = TRUE)
DatabaseConnector::renderTranslateExecuteSql(connection, "INSERT INTO @database_schema.cdm_source VALUES ('foo',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);", database_schema = cdmDatabaseSchemaEunomia)

w <- capture_warnings(
results <- executeDqChecks(
connectionDetails = connectionDetailsEunomiaCS,
cdmDatabaseSchema = cdmDatabaseSchemaEunomia,
resultsDatabaseSchema = resultsDatabaseSchemaEunomia,
cdmSourceName = "Eunomia",
checkNames = "measurePersonCompleteness",
outputFolder = outputFolder,
writeToTable = F
))

expect_match(w, "Missing check names", all = FALSE)
expect_match(w, "The cdm_source table has", all = FALSE)

expect_true(nrow(results$CheckResults) > 1)
})

0 comments on commit 16990b4

Please sign in to comment.