-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathspec-meta-get-statement.R
42 lines (41 loc) · 1.21 KB
/
spec-meta-get-statement.R
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
#' spec_meta_get_statement
#' @family meta specifications
#' @usage NULL
#' @format NULL
#' @keywords NULL
spec_meta_get_statement <- list(
get_statement_formals = function() {
# <establish formals of described functions>
expect_equal(names(formals(dbGetStatement)), c("res", "..."))
},
get_statement_query = function(con) {
#' @return
#' `dbGetStatement()` returns a string, the query used in
query <- trivial_query()
#' either [dbSendQuery()] or
res <- local_result(dbSendQuery(con, query))
s <- dbGetStatement(res)
expect_type(s, "character")
expect_identical(s, query)
},
#
get_statement_statement = function(con, table_name) {
query <- paste0("CREATE TABLE ", table_name, " (a integer)")
#' [dbSendStatement()].
res <- local_result(dbSendStatement(con, query))
s <- dbGetStatement(res)
expect_type(s, "character")
expect_identical(s, query)
},
#'
get_statement_error = function(con) {
#' @section Failure modes:
res <- dbSendQuery(con, trivial_query())
dbClearResult(res)
#' Attempting to query the statement for a result set cleared with
#' [dbClearResult()] gives an error.
expect_error(dbGetStatement(res))
},
#
NULL
)