tests/manualtest/test-database.R

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")
})
          
dmenne/dmrixml documentation built on May 15, 2019, 9:32 a.m.