tests/testthat/test-waitForNotify.R

test_that("WaitForNotify without anything to do returns NULL", {
  db <- postgresDefault()
  n <- RPostgres::postgresWaitForNotify(db, 1)
  dbDisconnect(db)
  expect_null(n)
})

test_that("WaitForNotify with a waiting message returns message", {
  db <- postgresDefault()
  dbExecute(db, 'LISTEN grapevine')
  dbExecute(db, "NOTIFY grapevine, 'psst'")
  n <- RPostgres::postgresWaitForNotify(db, 1)
  dbDisconnect(db)
  expect_identical(n$payload, 'psst')
})

Try the RPostgres package in your browser

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

RPostgres documentation built on Oct. 23, 2023, 1:06 a.m.