1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
test_that("RPostgreSQL backend", {
skip_if_not(identical(Sys.getenv("GITHUB_POSTGRES"), "true"))
src <- DBI::dbConnect(
RPostgreSQL::PostgreSQL(),
dbname = "test",
user = "postgres",
password = "password",
host = "127.0.0.1"
)
copy_to(src, mtcars, "mtcars", overwrite = TRUE, temporary = FALSE)
withr::defer(DBI::dbRemoveTable(src, "mtcars"))
expect_identical(colnames(tbl(src, "mtcars")), colnames(mtcars))
src_cyl <- tbl(src, "mtcars") %>% select(cyl) %>% collect()
expect_identical(src_cyl$cyl, mtcars$cyl)
})
|