improve error handling on database connector jar setings.
This commit is contained in:
parent
1bcb2236e8
commit
428420ec94
|
@ -1,7 +1,30 @@
|
||||||
|
# Specify desired test platforms
|
||||||
|
cdmVersion <- "5.4"
|
||||||
|
testDatabases <- c("postgresql")
|
||||||
|
|
||||||
# Download the JDBC drivers used in the tests
|
# Download the JDBC drivers used in the tests
|
||||||
library(DatabaseConnector)
|
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()
|
driverPath <- tempdir()
|
||||||
cat("\ndownloading drivers\n")
|
cat("\ndownloading drivers\n")
|
||||||
downloadJdbcDrivers("redshift", pathToDriver = driverPath)
|
downloadJdbcDrivers("redshift", pathToDriver = driverPath)
|
||||||
|
@ -12,7 +35,7 @@ if (is.na(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) {
|
||||||
driverPath <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER")
|
driverPath <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper functions used in tests -----------------------------------------------
|
# Helper functions used in tests
|
||||||
getConnectionDetails <- function(dbms) {
|
getConnectionDetails <- function(dbms) {
|
||||||
switch (dbms,
|
switch (dbms,
|
||||||
"postgresql" = createConnectionDetails(
|
"postgresql" = createConnectionDetails(
|
||||||
|
|
|
@ -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", {
|
test_that("getConnectionDetails works", {
|
||||||
for(dbms in testDatabases) {
|
for(dbms in testDatabases) {
|
||||||
|
|
Loading…
Reference in New Issue