tests/testthat/test-flights.R

context("flights")
library(nycflights13)

m <- mongo("test_flights", verbose = FALSE)
if(m$count()) m$drop()

test_that("insert data", {
  m$insert(flights)
  expect_equal(m$count(), nrow(flights))
  jan1 <- m$find('{"month":1, "day":1}')
  expect_equal(m$count('{"month":1, "day":1}'), nrow(jan1))
})

test_that("remove data", {
  m$remove('{}')
  expect_equal(m$count(), 0L)
  expect_true(m$drop())
})

Try the mongolite package in your browser

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

mongolite documentation built on March 31, 2023, 7:11 p.m.