File: test-update_csv.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 (38 lines) | stat: -rw-r--r-- 950 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
context("update_csv")

df <- data.frame(id=1:3, name=c('red', 'blue', 'green'))
write.csv(df, file="df.csv", row.names=FALSE, quote = FALSE)

test_that("update_csv works", {
  skip_on_cran()

  if (!conn$collection_exists("books")) conn$collection_create("books")

  aa <- conn$update_csv("df.csv", name = "books")

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

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

  if (!conn$collection_exists("books")) conn$collection_create("books")
  aa <- update_csv(conn, "df.csv", name = "books")

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

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

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

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

# cleanup
unlink("df.csv")