File: spec-connection-get-info.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 (45 lines) | stat: -rw-r--r-- 1,136 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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#' spec_connection_get_info
#' @family connection specifications
#' @usage NULL
#' @format NULL
#' @keywords NULL
#' @rdname spec_get_info
spec_connection_get_info <- list(
  get_info_connection = function(con) {
    #' @return
    #' For objects of class [DBIConnection-class], `dbGetInfo()`
    info <- dbGetInfo(con)
    #' returns a named list
    expect_type(info, "list")

    info_names <- names(info)

    #' that contains at least the following components:
    #'
    necessary_names <- c(
      #' - `db.version`: version of the database server,
      "db.version",
      #' - `dbname`: database name,
      "dbname",
      #' - `username`: username to connect to the database,
      "username",
      #' - `host`: hostname of the database server,
      "host",
      #' - `port`: port on the database server.
      "port"
    )

    for (name in necessary_names) {
      eval(bquote(
        expect_true(.(name) %in% info_names)
      ))
    }

    #' It must not contain a `password` component.
    expect_false("password" %in% info_names)

    #' Components that are not applicable should be set to `NA`.
  },
  #
  NULL
)