File: test-backend-postgres-old.R

package info (click to toggle)
r-cran-dbplyr 2.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,376 kB
  • sloc: sh: 13; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (2)
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)
})