diff --git a/DESCRIPTION b/DESCRIPTION index f9f4246..b4159a2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,6 +36,7 @@ Imports: rlang, cli Suggests: + crew, terra, testthat (>= 3.0.0), withr diff --git a/tests/testthat/test-tar-terra.R b/tests/testthat/test-tar-terra.R index 4bdc8c0..e3a0d73 100644 --- a/tests/testthat/test-tar-terra.R +++ b/tests/testthat/test-tar-terra.R @@ -32,15 +32,32 @@ targets::tar_test("tar_terra_rast(zipfile=TRUE) works", { filetype = "GPKG", zipfile = TRUE ) - ) + ) }) targets::tar_make() + expect_true(all(is.na(targets::tar_meta()$error))) x <- targets::tar_read(test_terra_rast2) - y <- targets::tar_read(test_terra_rast3) expect_s4_class(x, "SpatRaster") - expect_snapshot( - x - ) + expect_snapshot(x) +}) + +targets::tar_test("tar_terra_rast() works with multiple workers (tests marshaling/unmarshaling)", { + targets::tar_script({ + targets::tar_option_set(controller = crew::crew_controller_local(workers = 2)) + list( + geotargets::tar_terra_rast( + rast1, + terra::rast(system.file("ex/elev.tif", package = "terra")) + ), + geotargets::tar_terra_rast( + rast2, + terra::rast(system.file("ex/elev.tif", package = "terra")) + ) + ) + }) + targets::tar_make() + expect_true(all(is.na(targets::tar_meta()$error))) + expect_s4_class(targets::tar_read(rast1), "SpatRaster") }) targets::tar_test("tar_terra_vect() works", { @@ -84,3 +101,23 @@ targets::tar_test("tar_terra_vect() works", { expect_equal(terra::values(x), terra::values(y)) expect_equal(terra::values(y), terra::values(z)) }) + +targets::tar_test("tar_terra_vect() works with multiple workers (tests marshaling/unmarshaling)", { + targets::tar_script({ + targets::tar_option_set(controller = crew::crew_controller_local(workers = 2)) + list( + geotargets::tar_terra_vect( + vect1, + terra::vect(system.file("ex", "lux.shp", package = "terra")) + ), + geotargets::tar_terra_vect( + vect2, + terra::vect(system.file("ex", "lux.shp", package = "terra")) + ) + ) + }) + targets::tar_make() + expect_true(all(is.na(targets::tar_meta()$error))) + expect_s4_class(targets::tar_read(vect1), "SpatVector") +}) +