context("Creating and filling sample database")
require(RODBC)
## Modify the following connection string to run tests
## Important: we assume that a default database is given
connection = '
DRIVER=SQL Server Native Client 11.0;
DATABASE=MRITestDatabase;
Trusted_Connection=Yes;
SERVER=DIETERPC\\SQLEXPRESS'
channel = odbcDriverConnect(connection)
if (class(channel) != "RODBC")
stop("!!!! +++ Check and correct the connection string in test-database.R\n\n")
test_that("Creating a database with drop does not throw", {
CreateMRIDatabase(channel,drop=TRUE)
})
test_that("Creating a database without drop throws when the files are there", {
CreateMRIDatabase(channel,drop=TRUE)
expect_error(CreateMRIDatabase(channel),"CREATE TABLE")
})
test_that("Creating a database with non-exisiting sql file throws", {
expect_error( CreateMRIDatabase(channel,sqlfile="notexists.txt"),
"does not exist")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.