debug tests on github

This commit is contained in:
Adam Black 2021-08-19 22:45:23 -04:00
parent d6d213c7f6
commit e68cb43854
2 changed files with 25 additions and 23 deletions

View File

@ -5,7 +5,7 @@ driverPath <- file.path(Sys.getenv("HOME"), "drivers")
if(!dir.exists(driverPath)) dir.create(driverPath)
if(Sys.getenv("LOCAL_TEST") != "TRUE") {
cat("downloading drivers")
cat("\ndownloading drivers\n")
downloadJdbcDrivers("redshift", pathToDriver = driverPath)
downloadJdbcDrivers("postgresql", pathToDriver = driverPath)
downloadJdbcDrivers("oracle", pathToDriver = driverPath)
@ -57,6 +57,7 @@ getSchema <- function(dbms) {
listTablesInSchema <- function(connectionDetails, schema) {
stopifnot(class(connectionDetails) == "connectionDetails", class(schema) == "character", length(schema) == 1)
stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle"))
con <- DatabaseConnector::connect(connectionDetails)
on.exit(DatabaseConnector::disconnect(con))
dbms <- connectionDetails$dbms
@ -71,6 +72,7 @@ listTablesInSchema <- function(connectionDetails, schema) {
dropAllTablesFromSchema <- function(connectionDetails, schema) {
stopifnot(class(connectionDetails) == "connectionDetails", class(schema) == "character", length(schema) == 1)
stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle"))
tables <- listTablesInSchema(connectionDetails, schema)
con <- DatabaseConnector::connect(connectionDetails)

View File

@ -25,26 +25,26 @@ for(dbms in testDatabases) {
})
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)
})
}
# 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)
# })
# }
}