2021-08-19 20:00:24 +00:00
|
|
|
|
2021-08-20 02:23:39 +00:00
|
|
|
test_that("getConnectionDetails works", {
|
|
|
|
for(dbms in testDatabases) {
|
2023-09-07 17:52:20 +00:00
|
|
|
expect_s3_class(getConnectionDetails(dbms), "ConnectionDetails")
|
2021-08-19 03:35:38 +00:00
|
|
|
}
|
2021-08-20 02:23:39 +00:00
|
|
|
})
|
2021-08-19 19:17:01 +00:00
|
|
|
|
2021-08-20 02:23:39 +00:00
|
|
|
test_that("getSchema works", {
|
|
|
|
for(dbms in testDatabases) {
|
|
|
|
expect_type(getSchema(dbms), "character")
|
2021-08-19 19:17:01 +00:00
|
|
|
}
|
2021-08-19 03:35:38 +00:00
|
|
|
})
|
2021-08-19 12:13:03 +00:00
|
|
|
|
2021-08-20 02:23:39 +00:00
|
|
|
for(dbms in testDatabases) {
|
|
|
|
connectionDetails <- getConnectionDetails(dbms)
|
|
|
|
cdmDatabaseSchema <- getSchema(dbms)
|
2021-08-19 19:17:01 +00:00
|
|
|
|
2021-08-20 02:23:39 +00:00
|
|
|
test_that(paste("Can connect to", dbms), {
|
2021-08-20 03:38:29 +00:00
|
|
|
expect_error(con <- connect(connectionDetails), NA)
|
2021-08-20 03:12:55 +00:00
|
|
|
expect_error(disconnect(con), NA)
|
2021-08-20 02:23:39 +00:00
|
|
|
})
|
2021-08-19 19:17:01 +00:00
|
|
|
|
|
|
|
|
2021-08-20 03:58:18 +00:00
|
|
|
for(cdmVersion in listSupportedVersions()) {
|
|
|
|
test_that(paste("DDL", cdmVersion, "runs on", dbms), {
|
|
|
|
dropAllTablesFromSchema(connectionDetails, cdmDatabaseSchema)
|
|
|
|
tables <- listTablesInSchema(connectionDetails, cdmDatabaseSchema)
|
|
|
|
expect_equal(tables, character(0))
|
|
|
|
|
|
|
|
executeDdl(connectionDetails,
|
|
|
|
cdmVersion = cdmVersion,
|
|
|
|
cdmDatabaseSchema = cdmDatabaseSchema,
|
|
|
|
executeDdl = TRUE,
|
|
|
|
executePrimaryKey = TRUE,
|
|
|
|
executeForeignKey = FALSE)
|
|
|
|
|
|
|
|
tables <- listTablesInSchema(connectionDetails, cdmDatabaseSchema)
|
|
|
|
cdmTableCsvLoc <- system.file(file.path("csv", paste0("OMOP_CDMv", cdmVersion, "_Table_Level.csv")), package = "CommonDataModel", mustWork = TRUE)
|
|
|
|
tableSpecs <- read.csv(cdmTableCsvLoc, stringsAsFactors = FALSE)$cdmTableName
|
|
|
|
|
|
|
|
# check that the tables in the database match the tables in the specification
|
|
|
|
expect_equal(sort(tolower(tables)), sort(tolower(tableSpecs)))
|
|
|
|
dropAllTablesFromSchema(connectionDetails, cdmDatabaseSchema)
|
|
|
|
})
|
|
|
|
}
|
2021-08-20 02:23:39 +00:00
|
|
|
}
|