boB Rudis
4 years ago
57 changed files with 726 additions and 556 deletions
@ -0,0 +1,57 @@ |
|||
test_host <- Sys.getenv("DRILL_TEST_HOST", "localhost") |
|||
|
|||
options(sergeant.bigint.warnonce = FALSE) |
|||
|
|||
if (at_home()) { |
|||
|
|||
expect_visible <- function(code) { |
|||
ret <- withVisible(code) |
|||
expect_true(ret$visible) |
|||
ret$value |
|||
} |
|||
|
|||
connect <- function (drv) { |
|||
connect_call <- as.call(c(list(quote(dbConnect), drv))) |
|||
connect_fun <- function() {} |
|||
body(connect_fun) <- connect_call |
|||
connect_fun() |
|||
} |
|||
|
|||
dr <- Drill() |
|||
|
|||
expect_true(inherits(dr, "DBIDriver")) |
|||
expect_true(inherits(dbGetInfo(dr), "list")) |
|||
expect_true(all(names(dbGetInfo(dr)) %in% c("driver.version", "client.version"))) |
|||
|
|||
expect_equal(names(formals(dbConnect)), c("drv", "...")) |
|||
expect_equal(names(formals(dbDisconnect)), c("conn", "...")) |
|||
|
|||
con <- expect_visible(dbConnect(dr, test_host)) |
|||
expect_true(inherits(con, "DBIConnection")) |
|||
expect_true(dbDisconnect(con)) |
|||
|
|||
expect_true(inherits(dbGetInfo(con), "list")) |
|||
|
|||
expect_true(inherits(format(con), "character")) |
|||
|
|||
expect_equal(names(formals(dbDataType)), c("dbObj", "obj", "...")) |
|||
|
|||
expect_error(dbDataType(con, NULL)) |
|||
|
|||
expect_identical(dbDataType(con, letters), dbDataType(con, factor(letters))) |
|||
expect_identical(dbDataType(con, letters), dbDataType(con, ordered(letters))) |
|||
|
|||
expect_true( |
|||
all(c("db.version", "dbname", "username", "host", "port") %in% names(dbGetInfo(con))) |
|||
) |
|||
|
|||
expect_false("password" %in% names(dbGetInfo(con))) |
|||
|
|||
expect_equal(names(formals(dbListFields)), c("conn", "name", "...")) |
|||
|
|||
fields <- dbListFields(con, "cp.`employee.json`") |
|||
expect_true(inherits(fields, "character")) |
|||
|
|||
expect_warning(dbListFields(con, "missing")) |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
test_host <- Sys.getenv("DRILL_TEST_HOST", "localhost") |
|||
|
|||
options(sergeant.bigint.warnonce = FALSE) |
|||
|
|||
if (at_home()) { |
|||
|
|||
dc <- drill_connection(test_host) |
|||
expect_true(drill_active(dc)) |
|||
|
|||
suppressMessages( |
|||
drill_query(dc, "SELECT * FROM cp.`employee.json` limit 10", .progress = FALSE) |
|||
) -> test_rest |
|||
|
|||
expect_true(inherits(test_rest, "data.frame")) |
|||
|
|||
expect_true(inherits(drill_version(dc), "character")) |
|||
expect_true(inherits(drill_metrics(dc), "list")) |
|||
expect_true(inherits(drill_options(dc), "tbl")) |
|||
|
|||
dp <- drill_profiles(dc) |
|||
|
|||
expect_true(inherits(dp, "list")) |
|||
|
|||
expect_true( |
|||
inherits( |
|||
drill_profile(dc, dp$finishedQueries[1]$queryId[1]), |
|||
"list" |
|||
) |
|||
) |
|||
|
|||
suppressMessages( |
|||
expect_true( |
|||
drill_cancel(dc, dp$finishedQueries[1]$queryId[1]) |
|||
) |
|||
) |
|||
|
|||
suppressMessages( |
|||
suppressWarnings( |
|||
expect_true( |
|||
inherits( |
|||
drill_show_files(dc, schema_spec = "dfs"), |
|||
"tbl" |
|||
) |
|||
) |
|||
) |
|||
) |
|||
|
|||
expect_true(inherits(drill_show_schemas(dc), "tbl")) |
|||
expect_true(inherits(drill_storage(dc), "tbl")) |
|||
expect_true(inherits(drill_stats(dc), "list")) |
|||
expect_true(inherits(drill_status(dc), "html")) |
|||
expect_true(inherits(drill_threads(dc), "html")) |
|||
expect_true(inherits(drill_use(dc, "cp"), "tbl")) |
|||
|
|||
expect_true( |
|||
inherits( |
|||
drill_set( |
|||
dc, |
|||
exec.errors.verbose = TRUE, |
|||
store.format = "parquet", |
|||
web.logs.max_lines = 20000 |
|||
), |
|||
"tbl" |
|||
) |
|||
) |
|||
|
|||
} |
@ -1,5 +0,0 @@ |
|||
library(dbplyr) |
|||
library(sergeant) |
|||
library(testthat) |
|||
|
|||
test_check("sergeant") |
@ -1,58 +0,0 @@ |
|||
test_host <- Sys.getenv("DRILL_TEST_HOST", "localhost") |
|||
|
|||
options(sergeant.bigint.warnonce = FALSE) |
|||
|
|||
testthat::skip_on_cran() |
|||
|
|||
expect_visible <- function(code) { |
|||
ret <- withVisible(code) |
|||
expect_true(ret$visible) |
|||
ret$value |
|||
} |
|||
|
|||
connect <- function (drv) { |
|||
connect_call <- as.call(c(list(quote(dbConnect), drv))) |
|||
connect_fun <- function() {} |
|||
body(connect_fun) <- connect_call |
|||
connect_fun() |
|||
} |
|||
|
|||
context("r-lib dbi interface test") |
|||
|
|||
dr <- Drill() |
|||
|
|||
expect_s4_class(dr, "DBIDriver") |
|||
expect_is(dbGetInfo(dr), "list") |
|||
expect_true(all(names(dbGetInfo(dr)) %in% c("driver.version", "client.version"))) |
|||
|
|||
expect_equal(names(formals(dbConnect)), c("drv", "...")) |
|||
expect_equal(names(formals(dbDisconnect)), c("conn", "...")) |
|||
|
|||
con <- expect_visible(dbConnect(dr, test_host)) |
|||
expect_s4_class(con, "DBIConnection") |
|||
expect_true(dbDisconnect(con)) |
|||
|
|||
expect_is(dbGetInfo(con), "list") |
|||
|
|||
expect_is(format(con), "character") |
|||
|
|||
expect_equal(names(formals(dbDataType)), c("dbObj", "obj", "...")) |
|||
|
|||
expect_error(dbDataType(con, NULL)) |
|||
|
|||
expect_identical(dbDataType(con, letters), dbDataType(con, factor(letters))) |
|||
expect_identical(dbDataType(con, letters), dbDataType(con, ordered(letters))) |
|||
|
|||
expect_true( |
|||
all(c("db.version", "dbname", "username", "host", "port") %in% names(dbGetInfo(con))) |
|||
) |
|||
|
|||
expect_false("password" %in% names(dbGetInfo(con))) |
|||
|
|||
expect_equal(names(formals(dbListFields)), c("conn", "name", "...")) |
|||
|
|||
fields <- dbListFields(con, "cp.`employee.json`") |
|||
expect_is(fields, "character") |
|||
|
|||
expect_warning(dbListFields(con, "missing")) |
|||
|
@ -1,50 +0,0 @@ |
|||
test_host <- Sys.getenv("DRILL_TEST_HOST", "localhost") |
|||
|
|||
options(sergeant.bigint.warnonce = FALSE) |
|||
|
|||
context("REST API") |
|||
test_that("REST API works", { |
|||
|
|||
testthat::skip_on_cran() |
|||
|
|||
dc <- drill_connection(test_host) |
|||
expect_that(drill_active(dc), equals(TRUE)) |
|||
|
|||
suppressMessages( |
|||
drill_query(dc, "SELECT * FROM cp.`employee.json` limit 10", .progress = FALSE) |
|||
) -> test_rest |
|||
|
|||
expect_that(test_rest, is_a("data.frame")) |
|||
|
|||
expect_that(drill_version(dc), is_a("character")) |
|||
expect_that(drill_metrics(dc), is_a("list")) |
|||
expect_that(drill_options(dc), is_a("tbl")) |
|||
|
|||
dp <- drill_profiles(dc) |
|||
|
|||
expect_that(dp, is_a("list")) |
|||
expect_that(drill_profile(dc, dp$finishedQueries[1]$queryId[1]), is_a("list")) |
|||
suppressMessages( |
|||
expect_that(drill_cancel(dc, dp$finishedQueries[1]$queryId[1]), equals(TRUE)) |
|||
) |
|||
suppressMessages( |
|||
suppressWarnings( |
|||
expect_that(drill_show_files(dc, schema_spec = "dfs"), is_a("tbl")) |
|||
) |
|||
) |
|||
expect_that(drill_show_schemas(dc), is_a("tbl")) |
|||
expect_that(drill_storage(dc), is_a("tbl")) |
|||
expect_that(drill_stats(dc), is_a("list")) |
|||
expect_that(drill_status(dc), is_a("html")) |
|||
expect_that(drill_threads(dc), is_a("html")) |
|||
expect_that(drill_use(dc, "cp"), is_a("tbl")) |
|||
expect_that( |
|||
drill_set( |
|||
dc, |
|||
exec.errors.verbose=TRUE, |
|||
store.format="parquet", |
|||
web.logs.max_lines=20000), |
|||
is_a("tbl") |
|||
) |
|||
|
|||
}) |
@ -0,0 +1,5 @@ |
|||
|
|||
if ( requireNamespace("tinytest", quietly=TRUE) ){ |
|||
tinytest::test_package("sergeant") |
|||
} |
|||
|
Loading…
Reference in new issue