tests/testthat/test_dev.r

test_that("Source code should not have things on TODO list", {
  skip_on_ci()
  skip_on_cran()
  skip_if(length(unclass(packageVersion("CopernicusMarine"))[[1]]) > 3,
          "Skipping during development")
            
  expect_false({
    files_to_check <-
      list.files(system.file(package = "CopernicusMarine"),
                 pattern = "[.]r$|NEWS|DESCRIPTION|README", recursive = TRUE, full.names = TRUE)
    files_to_check <- files_to_check[!endsWith(files_to_check, "test_dev.r") &
                                       !endsWith(files_to_check, ".png")]
    any(
      unlist(
        lapply(files_to_check, function(file) {
          content <- suppressWarnings(readLines(file))
          result  <- grepl("TODO", content) & !grepl("grepl\\(\"TODO\"", content) & !grepl("on TODO list", content)
          if (any(result)) {
            warning(sprintf("File `%s` has items on TODO list at lines `%s`", file, paste(which(result), collapse = "`, `")))
          }
          any(result)
        })
      )
    )
  })
})

test_that("Missing blosc support throws error", {
  skip_if(!has_blosc)
  skip_on_cran()

  expect_error({
    fn <- tempfile("blosc", fileext = ".zarr")
    stars::write_stars(stars::st_as_stars(matrix(0, 10, 10)), fn, driver = "Zarr",
                       options = c("COMPRESS=BLOSC", "BLOSC_CNAME=zstd"))
    on.exit({unlink(fn, TRUE)})
    CopernicusMarine:::.check_vsi(fn, fn, FALSE)
  }, "Required BLOSC decompressor not available")
})

test_that("Unsupported formats throw error", {
  expect_error({
    CopernicusMarine:::.check_vsi(".foobar", ".foobar", FALSE)
  }, "No driver found")
})

Try the CopernicusMarine package in your browser

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

CopernicusMarine documentation built on Feb. 26, 2026, 9:07 a.m.