tests/testthat/test-otb-run-contract.R

# tests/testthat/test-runotb-contract.R

testthat::test_that("runOTB() enforces basic command-list contract", {
  gili <- list(exist = TRUE, otbCmd = "otbcli", launcher = "otbApplicationLauncherCommandLine")
  
  testthat::expect_error(
    link2GI::runOTB(NULL, gili = gili, retCommand = TRUE),
    regexp = "is\\.list\\(otbCmdList\\) is not TRUE"
  )
  
  testthat::expect_error(
    link2GI::runOTB(list(), gili = gili, retCommand = TRUE),
    regexp = "length\\(otbCmdList\\) > 0 is not TRUE"
  )
  
  testthat::expect_error(
    link2GI::runOTB(list(1, 2, 3), gili = gili, retCommand = TRUE),
    regexp = NA
  )
})

testthat::test_that("runOTB() fails clearly when gili is invalid", {
  cmd <- list("DimensionalityReduction", `in` = "in.tif", out = "out.tif")
  
  testthat::expect_error(
    link2GI::runOTB(cmd, gili = NULL, retCommand = TRUE),
    "No valid OTB installation found",
    fixed = TRUE
  )
})

Try the link2GI package in your browser

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

link2GI documentation built on Dec. 23, 2025, 9:09 a.m.