File: test-schema.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 (48 lines) | stat: -rw-r--r-- 1,450 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
44
45
46
47
48
context("schema - cloud mode")

test_that("both R6 and normal function call work", {
  skip_on_cran()

  expect_is(conn$schema, "function")
  expect_equal(names(formals(schema))[1], "conn")
})

test_that("schema works against", {
  skip_on_cran()
  skip_if_not(!is_in_cloud_mode(conn))

  aa <- conn$schema(name = "gettingstarted")
  bb <- conn$schema(name = "gettingstarted", what = "fields")

  expect_is(conn$schema(name = "gettingstarted", "dynamicfields"), "list")
  expect_is(conn$schema(name = "gettingstarted", "fieldtypes"), "list")
  expect_is(conn$schema(name = "gettingstarted", "copyfields"), "list")
  expect_is(conn$schema(name = "gettingstarted", "name"), "list")
  expect_is(conn$schema(name = "gettingstarted", "version"), "list")
  expect_is(conn$schema(name = "gettingstarted", "uniquekey"), "list")
  expect_is(conn$schema(name = "gettingstarted", "similarity"), "list")

  expect_is(aa, "list")
  expect_is(aa$responseHeader, "list")
  expect_is(aa$schema, "list")
  expect_is(aa$schema$name, "character")

  expect_is(bb, "list")
  expect_is(bb$fields, "data.frame")
})

test_that("schema fails well", {
  skip_on_cran()
  skip_if_not(!is_in_cloud_mode(conn))

  expect_error(conn$schema(), "argument \"name\" is missing")
  expect_error(conn$schema(name = "gettingstarted", "stuff"), "Not Found")
})

test_that("schema old style works", {
  skip_on_cran()

  expect_is(schema(conn, name = "gettingstarted"),
    "list"
  )
})