File: test-db-io.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 (30 lines) | stat: -rw-r--r-- 711 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
test_that("db_copy_to() wraps DBI errors", {
  con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
  on.exit(DBI::dbDisconnect(con))
  DBI::dbWriteTable(con, "tmp", data.frame(x = 1), overwrite = TRUE, temporary = TRUE)

  # error when writing
  expect_snapshot(
    (expect_error(
      db_copy_to(
        con = con,
        table = "tmp",
        values = data.frame(x = c(1, 1))
      )
    )),
    transform = snap_transform_dbi
  )

  # error when creating unique index
  expect_snapshot(
    (expect_error(
      db_copy_to(
        con = con,
        table = "tmp2",
        values = data.frame(x = c(1, 1)),
        unique_indexes = list("x")
      )
    )),
    transform = snap_transform_dbi
  )
})