File: spec-connection-disconnect.R

package info (click to toggle)
r-cran-dbitest 1.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,216 kB
  • sloc: sh: 10; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,106 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
31
32
33
34
35
36
37
#' spec_connection_disconnect
#' @family connection specifications
#' @usage NULL
#' @format NULL
#' @keywords NULL
spec_connection_disconnect <- list(
  disconnect_formals = function() {
    # <establish formals of described functions>
    expect_equal(names(formals(dbDisconnect)), c("conn", "..."))
  },

  can_disconnect = function(ctx) {
    #' @return
    con <- connect(ctx)
    #' `dbDisconnect()` returns `TRUE`, invisibly.
    expect_invisible_true(dbDisconnect(con))
  },

  #'
  #' @section Failure modes:
  #' A warning is issued on garbage collection when a connection has been
  #' released without calling `dbDisconnect()`,
  #' but this cannot be tested automatically.

  disconnect_closed_connection = function(ctx, closed_con) {
    #' At least one warning is issued immediately when calling `dbDisconnect()` on an
    #' already disconnected
    suppressWarnings(expect_warning(dbDisconnect(closed_con)))
  },

  disconnect_invalid_connection = function(ctx, invalid_con) {
    #' or invalid connection.
    suppressWarnings(expect_warning(dbDisconnect(invalid_con)))
  },
  #
  NULL
)