-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Schuemie
authored and
Schuemie
committed
Oct 21, 2023
1 parent
2b6e31c
commit faa68ea
Showing
8 changed files
with
186 additions
and
1,290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,10 @@ | ||
library(testthat) | ||
|
||
test_that("Compute data hash", { | ||
# Postgresql ----------------------------------------------------------------- | ||
details <- createConnectionDetails( | ||
dbms = "postgresql", | ||
user = Sys.getenv("CDM5_POSTGRESQL_USER"), | ||
password = URLdecode(Sys.getenv("CDM5_POSTGRESQL_PASSWORD")), | ||
server = Sys.getenv("CDM5_POSTGRESQL_SERVER") | ||
) | ||
connection <- connect(details) | ||
hash <- computeDataHash(connection, Sys.getenv("CDM5_POSTGRESQL_CDM54_SCHEMA")) | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
|
||
# SQL Server ----------------------------------------------------------------- | ||
details <- createConnectionDetails( | ||
dbms = "sql server", | ||
user = Sys.getenv("CDM5_SQL_SERVER_USER"), | ||
password = URLdecode(Sys.getenv("CDM5_SQL_SERVER_PASSWORD")), | ||
server = Sys.getenv("CDM5_SQL_SERVER_SERVER") | ||
) | ||
connection <- connect(details) | ||
hash <- computeDataHash(connection, Sys.getenv("CDM5_SQL_SERVER_CDM54_SCHEMA")) | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
|
||
# Oracle --------------------------------------------------------------------- | ||
details <- createConnectionDetails( | ||
dbms = "oracle", | ||
user = Sys.getenv("CDM5_ORACLE_USER"), | ||
password = URLdecode(Sys.getenv("CDM5_ORACLE_PASSWORD")), | ||
server = Sys.getenv("CDM5_ORACLE_SERVER") | ||
) | ||
connection <- connect(details) | ||
hash <- computeDataHash(connection, Sys.getenv("CDM5_ORACLE_CDM54_SCHEMA")) | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
|
||
# RedShift ------------------------------------------------------------------ | ||
details <- createConnectionDetails( | ||
dbms = "redshift", | ||
user = Sys.getenv("CDM5_REDSHIFT_USER"), | ||
password = URLdecode(Sys.getenv("CDM5_REDSHIFT_PASSWORD")), | ||
server = Sys.getenv("CDM5_REDSHIFT_SERVER") | ||
) | ||
connection <- connect(details) | ||
hash <- computeDataHash(connection, Sys.getenv("CDM5_REDSHIFT_CDM54_SCHEMA")) | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
|
||
# RSQLite -------------------------------------------------------------------- | ||
dbFile <- tempfile(fileext = "sqlite") | ||
details <- createConnectionDetails( | ||
dbms = "sqlite", | ||
server = dbFile | ||
) | ||
connection <- connect(details) | ||
DatabaseConnector::insertTable( | ||
connection = connection, | ||
databaseSchema = "main", | ||
tableName = "cars", | ||
data = cars, | ||
createTable = TRUE | ||
) | ||
DatabaseConnector::insertTable( | ||
connection = connection, | ||
databaseSchema = "main", | ||
tableName = "iris", | ||
data = iris, | ||
createTable = TRUE | ||
) | ||
hash <- computeDataHash(connection, "main") | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
unlink(dbFile) | ||
|
||
# DuckDB -------------------------------------------------------------------- | ||
dbFile <- tempfile(fileext = "duckdb") | ||
details <- createConnectionDetails( | ||
dbms = "duckdb", | ||
server = dbFile | ||
) | ||
connection <- connect(details) | ||
DatabaseConnector::insertTable( | ||
connection = connection, | ||
databaseSchema = "main", | ||
tableName = "cars", | ||
data = cars, | ||
createTable = TRUE | ||
) | ||
DatabaseConnector::insertTable( | ||
connection = connection, | ||
databaseSchema = "main", | ||
tableName = "iris", | ||
data = iris, | ||
createTable = TRUE | ||
) | ||
hash <- computeDataHash(connection, "main") | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
unlink(dbFile) | ||
|
||
# Snowflake ------------------------------------------------------------------ | ||
details <- createConnectionDetails( | ||
dbms = "snowflake", | ||
user = Sys.getenv("CDM_SNOWFLAKE_USER"), | ||
password = URLdecode(Sys.getenv("CDM_SNOWFLAKE_PASSWORD")), | ||
connectionString = Sys.getenv("CDM_SNOWFLAKE_CONNECTION_STRING") | ||
) | ||
connection <- connect(details) | ||
hash <- computeDataHash(connection, Sys.getenv("CDM_SNOWFLAKE_CDM53_SCHEMA")) | ||
expect_true(is.character(hash)) | ||
|
||
disconnect(connection) | ||
}) | ||
for (testServer in testServers) { | ||
test_that(addDbmsToLabel("Compute data hash", testServer), { | ||
connection <- connect(testServer$connectionDetails) | ||
on.exit(disconnect(connection)) | ||
hash <- computeDataHash(connection, testServer$cdmDatabaseSchema) | ||
expect_true(is.character(hash)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.