test_that("versions", {
  v <- baad_data_versions(FALSE)
  expect_true("1.0.0" %in% v)
  expect_equal(match("1.0.0", v), 4)

  curr <- baad_data_version_current(FALSE)
  expect_true(numeric_version(curr) >= numeric_version("1.0.0"))
  expect_true(curr %in% v)

test_that("ecology version", {
  path <- tempfile()
  d <- baad_data("1.0.0", path)

  # Note, we are just checking the data component here,
  # because the whole `data` object was behaving differently
  # on different platforms, due to slightly different behaviours
  # of bibtex package.
  # In addition, we are taking has of data after calling `as.character(unlist`
  # because appveyor gives different hash when NAs are present, even if
  # other tests show contents as all.equal
  # See https://github.com/traitecoevo/baad.data/issues/6


  expect_is(d, "list")
  expect_is(d$data, "data.frame")

  expect_identical(baad_data("1.0.0", path), d)

  expect_true("1.0.0" %in% baad_data_versions(TRUE, path))

  v <- baad_data_versions(FALSE, path)
  res <- list()
  for (i in v) {
    res[[i]] <- baad_data(i, path)
    expect_is(res[[i]]$data,   "data.frame")
    expect_is(res[[i]]$dictionary, "data.frame")
    expect_is(res[[i]]$bib,        "bibentry")

  expect_equal(baad_data_versions(TRUE, path),
              baad_data_versions(FALSE, path))

  baad_data_del("1.0.0", path)
  expect_false("1.0.0" %in% baad_data_versions(TRUE, path))
  baad_data_del(NULL, path)

  d <- baad_data("1.0.0")
  path <- file.path(getwd(), "baad_1.0.0.rds")
  saveRDS(d, path)
traitecoevo/baad.data documentation built on May 31, 2019, 7:42 p.m.