Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix tests when dplyr is missing #29

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/backend-dbplyr__duckdb_connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @name backend-duckdb
#' @aliases NULL
#' @examples
#' @examplesIf rlang::is_installed("dbplyr")
#' library(dplyr, warn.conflicts = FALSE)
#' con <- DBI::dbConnect(duckdb(), path = ":memory:")
#'
Expand Down
2 changes: 2 additions & 0 deletions man/backend-duckdb.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test_arrow_stream.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
skip_on_cran()
skip_on_os("windows")
skip_if_not_installed("arrow", "5.0.0")
skip_if_not_installed("dbplyr")

library("testthat")
library("DBI")
Expand Down
18 changes: 15 additions & 3 deletions tests/testthat/test_tbl__duckdb_connection.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
skip_on_cran()
`%>%` <- dplyr::`%>%`
if (rlang::is_installed("dbplyr")) {
`%>%` <- dplyr::`%>%`
}

test_that("Parquet files can be registered with dplyr::tbl()", {
skip_if_not_installed("dbplyr")

con <- DBI::dbConnect(duckdb())
on.exit(DBI::dbDisconnect(con, shutdown = TRUE))

Expand All @@ -24,6 +28,8 @@ test_that("Parquet files can be registered with dplyr::tbl()", {


test_that("Object cache can be enabled for parquet files with dplyr::tbl()", {
skip_if_not_installed("dbplyr")

con <- DBI::dbConnect(duckdb())
on.exit(DBI::dbDisconnect(con, shutdown = TRUE))

Expand All @@ -38,6 +44,8 @@ test_that("Object cache can be enabled for parquet files with dplyr::tbl()", {


test_that("CSV files can be registered with dplyr::tbl()", {
skip_if_not_installed("dbplyr")

path <- file.path(tempdir(), "duckdbtest.csv")
write.csv(iris, file = path)
on.exit(unlink(path))
Expand All @@ -55,6 +63,8 @@ test_that("CSV files can be registered with dplyr::tbl()", {
})

test_that("Other replacement scans or functions can be registered with dplyr::tbl()", {
skip_if_not_installed("dbplyr")

con <- DBI::dbConnect(duckdb())
on.exit(DBI::dbDisconnect(con, shutdown = TRUE))

Expand All @@ -64,12 +74,14 @@ test_that("Other replacement scans or functions can be registered with dplyr::tb
})

test_that("Strings tagged as SQL will be handled correctly with dplyr::tbl()", {
skip_if_not_installed("dbplyr")

con <- DBI::dbConnect(duckdb())
on.exit(DBI::dbDisconnect(con, shutdown = TRUE))

rs <- dplyr::tbl(con, dplyr::sql("SELECT 1"))
expect_true(inherits(rs, "tbl_duckdb_connection"))
expect_true(rs %>% dplyr::collect() == 1)
})

rm(`%>%`)
try(rm(`%>%`))
Loading