Skip to content

Commit

Permalink
Add a dummyPrestoConnection() function
Browse files Browse the repository at this point in the history
  • Loading branch information
jarodmeng committed Jan 13, 2023
1 parent 2883624 commit 786b86a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export(Presto)
export(add_chunk)
export(dbCreateTableAs)
export(dbRenameTable)
export(dummyPrestoConnection)
export(kerberos_configs)
export(presto_default)
export(presto_has_default)
Expand Down
15 changes: 15 additions & 0 deletions R/dbConnect.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,18 @@ setMethod(
return(conn)
}
)

#' A dummy PrestoConnection
#'
#' @export
#' @keywords internal
#' @examples
#' dummyPrestoConnection()
dummyPrestoConnection <- function() {
methods::new("PrestoConnection",
session.timezone = Sys.timezone(),
output.timezone = Sys.timezone(),
request.config = httr::config(),
session = PrestoSession$new(list(), list())
)
}
15 changes: 15 additions & 0 deletions man/dummyPrestoConnection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-dbQuoteLiteral.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ context("dbQuoteLiteral")

source("utilities.R")

test_that("dbQuoteLiteral works with live connection", {
conn <- presto_default()
test_that("dbQuoteLiteral works", {
conn <- dummyPrestoConnection()
expect_equal(dbQuoteLiteral(conn, DBI::SQL("foo")), DBI::SQL("foo"))
expect_equal(
dbQuoteLiteral(conn, factor(c("a", "b", NA_character_))),
Expand Down

0 comments on commit 786b86a

Please sign in to comment.