tests/testthat/test-BatchProcess.R

library(testthat)

fun <- function(data, position, myString) {
  data$test <- myString
  return(data)
}
args <- list(myString = "MY STRING")

for (testServer in testServers) {
  test_that(addDbmsToLabel("Open and close connection", testServer), {
    connection <- connect(testServer$connectionDetails)
    on.exit(disconnect(connection))
    sql <- "SELECT TOP 10 * FROM @cdm_database_schema.vocabulary;"
    data <- renderTranslateQueryApplyBatched(
      connection,
      sql,
      fun,
      args,
      cdm_database_schema = testServer$cdmDatabaseSchema
    )
    data <- do.call(rbind, data)
    expect_true("test" %in% colnames(data))
    expect_true(all(data$test == "MY STRING"))
  })
}

Try the DatabaseConnector package in your browser

Any scripts or data that you put into this service are public.

DatabaseConnector documentation built on May 29, 2024, 6:14 a.m.