diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 85be35e..8463382 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,7 +1,30 @@ +# Specify desired test platforms +cdmVersion <- "5.4" +testDatabases <- c("postgresql") + # Download the JDBC drivers used in the tests library(DatabaseConnector) -if (is.na(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) { +missingJarFolderEnvironmentVariable <- FALSE +emptyJarFolderEnivornmentVariable <- FALSE +jarFolderDoesNotExist <- FALSE + +missingJarFolderEnvironmentVariable <- is.na(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER")) +if (missingJarFolderEnvironmentVariable) { + cat("DATABASECONNECTOR_JAR_FOLDER environment variable not set.") +} else { + emptyJarFolderEnivornmentVariable <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER")=="" + if (emptyJarFolderEnivornmentVariable) { + cat("DATABASECONNECTOR_JAR_FOLDER environment variable is empty string") + } else { + jarFolderDoesNotExist <- !dir.exists(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER")) + if (jarFolderDoesNotExist) { + cat(paste("specified DATABASECONNECTOR_JAR_FOLDER", Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"), "does not exist.")) + } + } +} + +if ( missingJarFolderEnvironmentVariable| emptyJarFolderEnivornmentVariable | jarFolderDoesNotExist) { driverPath <- tempdir() cat("\ndownloading drivers\n") downloadJdbcDrivers("redshift", pathToDriver = driverPath) @@ -12,7 +35,7 @@ if (is.na(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) { driverPath <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") } -# Helper functions used in tests ----------------------------------------------- +# Helper functions used in tests getConnectionDetails <- function(dbms) { switch (dbms, "postgresql" = createConnectionDetails( diff --git a/tests/testthat/test-executeDdl.R b/tests/testthat/test-executeDdl.R index 30f0fe6..5a77829 100644 --- a/tests/testthat/test-executeDdl.R +++ b/tests/testthat/test-executeDdl.R @@ -1,10 +1,3 @@ -# To run tests for one dbms and one cdmVersion use the variables below -dbms <- "postgresql" -cdmVersion <- "5.4" -testDatabases <- c(dbms) - -# testDatabases <- c("oracle", "postgresql", "sql server", "redshift") -# testDatabases <- c("redshift") test_that("getConnectionDetails works", { for(dbms in testDatabases) {