tests/testthat/test-update_json.R

context("update_json")

skip_if(solr_missing(conn))
skip_on_ci()

test_that("update_json works", {
  skip_on_cran()

  file <- system.file("examples", "books2.json", package = "solrium")
  if (!conn$collection_exists("books")) conn$collection_create("books")
  aa <- conn$update_json(files = file, name = "books")

  expect_is(aa, "list")
  expect_named(aa, c("responseHeader"))
  expect_true(conn$collection_exists("books"))
})

test_that("update_json works with old format", {
  skip_on_cran()

  file <- system.file("examples", "books2.json", package = "solrium")
  if (!conn$collection_exists("books")) conn$collection_create("books")
  aa <- update_json(conn, files = file, name = "books")

  expect_is(aa, "list")
  expect_named(aa, c("responseHeader"))
  expect_true(conn$collection_exists("books"))
})

test_that("update_json fails well", {
  skip_on_cran()

  expect_error(update_json(), "argument \"conn\" is missing")

  expect_error(update_json(5), "conn must be a SolrClient object")
})

Try the solrium package in your browser

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

solrium documentation built on May 19, 2021, 9:06 a.m.