File: test-solr_get.R

package info (click to toggle)
r-cran-solrium 1.1.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,132 kB
  • sloc: xml: 374; sh: 13; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
context("get")

test_that("get works with a single id", {
  skip_on_cran()

  if (!collection_exists(conn, "gettingstarted")) {
    collection_create(conn, name = "gettingstarted", numShards = 1)
  }
  ss <- list(list(id = 1, price = 100), list(id = 2, price = 500))
  invisible(add(ss, conn, name = "gettingstarted"))

  aa <- solr_get(conn, ids = 1, "gettingstarted")

  expect_is(aa, "list")
  expect_named(aa, c("response"))
  expect_named(aa$response, c("numFound", "start", "docs"))
  expect_is(aa$response$docs, "data.frame")


  aa <- solr_get(conn, ids = c(1, 2), "gettingstarted")

  expect_is(aa, "list")
  expect_named(aa, c("response"))
  expect_equal(NROW(aa$response$docs), 2)

  aa <- solr_get(conn, ids = "1,2", "gettingstarted")

  expect_is(aa, "list")
  expect_named(aa, c("response"))
  expect_equal(NROW(aa$response$docs), 2)

  aa <- conn$get(1, "gettingstarted")

  expect_is(aa, "list")
  expect_named(aa$response, c("numFound", "start", "docs"))
})

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

  expect_error(solr_get(), "argument \"conn\" is missing")
  expect_error(solr_get(5), "conn must be a SolrClient object")
})