tests/testthat/test-connection.R

context("connection")

test_that("redis_connection", {
  skip_if_no_redis()
  con <- redis_connection()
  expect_true(setequal(names(con),
                       c("config", "reconnect", "command",
                         "pipeline", "subscribe")))
  expect_equal(con$command("PING"), redis_status("PONG"))

  tmp <- unserialize(serialize(con, NULL))
  expect_error(tmp$command("PING"), "Context is not connected")
  tmp$reconnect()
  expect_equal(con$command("PING"), redis_status("PONG"))

  ## Very trivial tests of the other methods:
  expect_is(con$config(), "redis_config")
  expect_equal(con$pipeline(list("PING", "PING")),
               rep(list(redis_status("PONG")), 2))
})

Try the redux package in your browser

Any scripts or data that you put into this service are public.

redux documentation built on Jan. 12, 2022, 5:09 p.m.