From e68cb43854aa5a872f8a5054ea1625854bf0093a Mon Sep 17 00:00:00 2001 From: Adam Black Date: Thu, 19 Aug 2021 22:45:23 -0400 Subject: [PATCH] debug tests on github --- tests/testthat/setup.R | 4 ++- tests/testthat/test-executeDdl.R | 44 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 9023838..60ea953 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -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) diff --git a/tests/testthat/test-executeDdl.R b/tests/testthat/test-executeDdl.R index 83cf366..15d178d 100644 --- a/tests/testthat/test-executeDdl.R +++ b/tests/testthat/test-executeDdl.R @@ -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) + # }) + # } }