diff --git a/tests/testthat/test-class_clustermq.R b/tests/testthat/test-class_clustermq.R index df778cd6..3eeebb05 100644 --- a/tests/testthat/test-class_clustermq.R +++ b/tests/testthat/test-class_clustermq.R @@ -181,7 +181,7 @@ tar_test("clustermq with a dynamic file", { suppressWarnings(cmq$run()) out <- names(cmq$scheduler$progress$completed$envir) expect_equal(out, "x") - saveRDS(2L, pipeline_get_target(pipeline, "x")$store$file$path) + saveRDS(2L, pipeline_get_target(pipeline, "x")$file$path) x <- tar_target_raw("x", quote(save1()), format = "file") pipeline <- pipeline_init(list(x)) cmq <- clustermq_init(pipeline) diff --git a/tests/testthat/test-class_cue.R b/tests/testthat/test-class_cue.R index 99a4c853..1c8d5d33 100644 --- a/tests/testthat/test-class_cue.R +++ b/tests/testthat/test-class_cue.R @@ -372,7 +372,7 @@ tar_test("cue_file()", { local$run() out <- counter_get_names(local$scheduler$progress$completed) expect_equal(out, "x") - saveRDS(2L, x$store$file$path) + saveRDS(2L, x$file$path) x <- target_init("x", quote(1L)) local <- local_init(pipeline_init(list(x))) local$run() @@ -432,7 +432,7 @@ tar_test("cue_file() suppressed", { local$run() out <- counter_get_names(local$scheduler$progress$completed) expect_equal(out, "x") - saveRDS(2L, x$store$file$path) + saveRDS(2L, x$file$path) x <- target_init("x", quote(1L), cue = cue) local <- local_init(pipeline_init(list(x))) local$run() @@ -453,7 +453,7 @@ tar_test("cue_file() on a dynamic file", { local$run() out <- counter_get_names(local$scheduler$progress$completed) expect_equal(out, "x") - saveRDS(2L, x$store$file$path) + saveRDS(2L, x$file$path) x <- target_init("x", quote(save1()), format = "file") local <- local_init(pipeline_init(list(x))) local$run() diff --git a/tests/testthat/test-class_feather.R b/tests/testthat/test-class_feather.R index 73b790b4..34d06e2b 100644 --- a/tests/testthat/test-class_feather.R +++ b/tests/testthat/test-class_feather.R @@ -17,7 +17,7 @@ tar_test("feather format", { exp <- envir$f() expect_equal( as.data.frame( - eval(parse(text = "arrow::read_feather"))(x$store$file$path) + eval(parse(text = "arrow::read_feather"))(x$file$path) ), as.data.frame(exp) ) @@ -130,9 +130,11 @@ tar_test("does not inherit from tar_external", { tar_test("store_row_path()", { skip_cran() skip_if_not_installed("arrow") - store <- tar_target(x, "x_value", format = "feather")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "feather") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_frames.R b/tests/testthat/test-class_frames.R index 6c53fb07..8a4ef187 100644 --- a/tests/testthat/test-class_frames.R +++ b/tests/testthat/test-class_frames.R @@ -92,8 +92,8 @@ tar_test("target_frames_deps()", { frames <- frames_init() tmp <- tempfile() saveRDS("value", tmp) - file <- x$store$file$path <- tmp - file <- y$store$file$path <- tmp + file <- x$file$path <- tmp + file <- y$file$path <- tmp expect_named(frames_get_envir(frames), character(0)) x <- pipeline_get_target(pipeline, "abc") y <- pipeline_get_target(pipeline, "def") diff --git a/tests/testthat/test-class_fst.R b/tests/testthat/test-class_fst.R index 9c76e57f..4a33a6df 100644 --- a/tests/testthat/test-class_fst.R +++ b/tests/testthat/test-class_fst.R @@ -14,7 +14,7 @@ tar_test("fst format", { builder_update_paths(x, path_store_default()) builder_update_object(x) exp <- envir$f() - expect_equal(fst::read_fst(x$store$file$path), exp) + expect_equal(fst::read_fst(x$file$path), exp) expect_equal(target_read_value(x)$object, exp) expect_silent(target_validate(x)) }) @@ -92,9 +92,11 @@ tar_test("does not inherit from tar_external", { tar_test("store_row_path()", { skip_if_not_installed("fst") - store <- tar_target(x, "x_value", format = "fst")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "fst") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_fst_dt.R b/tests/testthat/test-class_fst_dt.R index 50ab577c..6f44314f 100644 --- a/tests/testthat/test-class_fst_dt.R +++ b/tests/testthat/test-class_fst_dt.R @@ -15,7 +15,7 @@ tar_test("fst_dt format", { builder_update_paths(x, path_store_default()) builder_update_object(x) exp <- envir$f() - file <- x$store$file + file <- x$file out <- fst::read_fst(file$path, as.data.table = TRUE) expect_equal(out, exp) expect_equal(target_read_value(x)$object, exp) @@ -70,9 +70,11 @@ tar_test("does not inherit from tar_external", { tar_test("store_row_path()", { skip_if_not_installed("data.table") skip_if_not_installed("fst") - store <- tar_target(x, "x_value", format = "fst_dt")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "fst_dt") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_fst_tbl.R b/tests/testthat/test-class_fst_tbl.R index df712be4..fc4ee9e6 100644 --- a/tests/testthat/test-class_fst_tbl.R +++ b/tests/testthat/test-class_fst_tbl.R @@ -15,7 +15,7 @@ tar_test("fst_tbl format", { builder_update_paths(x, path_store_default()) builder_update_object(x) exp <- envir$f() - out <- tibble::as_tibble(fst::read_fst(x$store$file$path)) + out <- tibble::as_tibble(fst::read_fst(x$file$path)) expect_equal(out, exp) expect_equal(target_read_value(x)$object, exp) expect_silent(target_validate(x)) @@ -89,9 +89,11 @@ tar_test("does not inherit from tar_external", { tar_test("store_row_path()", { skip_if_not_installed("fst") skip_if_not_installed("tibble") - store <- tar_target(x, "x_value", format = "fst_tbl")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "fst_tbl") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_gcp.R b/tests/testthat/test-class_gcp.R index b5f35454..454cd382 100644 --- a/tests/testthat/test-class_gcp.R +++ b/tests/testthat/test-class_gcp.R @@ -33,14 +33,16 @@ tar_test("inherits from tar_external", { }) tar_test("store_row_path()", { - store <- tar_target( + target <- tar_target( x, "x_value", format = "feather", repository = "gcp" - )$store - store$file$path <- "path" - expect_equal(store_row_path(store), "path") + ) + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), "path") }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_gcp_file.R b/tests/testthat/test-class_gcp_file.R index f2bc051f..8c49a7ac 100644 --- a/tests/testthat/test-class_gcp_file.R +++ b/tests/testthat/test-class_gcp_file.R @@ -22,14 +22,16 @@ tar_test("inherits from tar_external", { }) tar_test("store_row_path()", { - store <- tar_target( + target <- tar_target( x, "x_value", format = "file", repository = "gcp" - )$store - store$file$path <- "path" - expect_equal(store_row_path(store), "path") + ) + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), "path") }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_keras.R b/tests/testthat/test-class_keras.R index 6f0ba5b7..6a85197c 100644 --- a/tests/testthat/test-class_keras.R +++ b/tests/testthat/test-class_keras.R @@ -20,9 +20,11 @@ tar_test("does not inherit from tar_external", { tar_test("store_row_path()", { skip_cran() - store <- tar_target(x, "x_value", format = "keras")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "keras") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_parquet.R b/tests/testthat/test-class_parquet.R index 75d03ebd..9c9b05af 100644 --- a/tests/testthat/test-class_parquet.R +++ b/tests/testthat/test-class_parquet.R @@ -17,7 +17,7 @@ tar_test("parquet format", { exp <- envir$f() expect_equal( as.data.frame( - eval(parse(text = "arrow::read_parquet"))(x$store$file$path) + eval(parse(text = "arrow::read_parquet"))(x$file$path) ), as.data.frame(exp) ) @@ -130,9 +130,11 @@ tar_test("does not inherit from tar_external", { tar_test("store_row_path()", { skip_cran() skip_if_not_installed("arrow") - store <- tar_target(x, "x_value", format = "parquet")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "parquet") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_qs.R b/tests/testthat/test-class_qs.R index 02493e8c..c0f1ae03 100644 --- a/tests/testthat/test-class_qs.R +++ b/tests/testthat/test-class_qs.R @@ -10,7 +10,7 @@ tar_test("qs format", { builder_update_paths(x, path_store_default()) builder_update_object(x) exp <- 2L - expect_equal(qs::qread(x$store$file$path), exp) + expect_equal(qs::qread(x$file$path), exp) expect_equal(target_read_value(x)$object, exp) expect_silent(target_validate(x)) }) @@ -70,9 +70,11 @@ tar_test("does not inherit from tar_external", { }) tar_test("store_row_path()", { - store <- tar_target(x, "x_value", format = "qs")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "qs") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_rds.R b/tests/testthat/test-class_rds.R index 12a4cf8b..e7feb0f1 100644 --- a/tests/testthat/test-class_rds.R +++ b/tests/testthat/test-class_rds.R @@ -2,12 +2,12 @@ tar_test("rds update_object()", { x <- target_init(name = "abc", expr = quote(a), format = "rds") builder_update_build(x, tmpenv(a = "123")) builder_update_paths(x, path_store_default()) - expect_false(file.exists(x$store$file$path)) - expect_true(is.na(x$store$file$hash)) + expect_false(file.exists(x$file$path)) + expect_true(is.na(x$file$hash)) store_update_stage_early(x$store, "abc", path_store_default()) builder_update_object(x) - expect_true(file.exists(x$store$file$path)) - expect_false(is.na(x$store$file$hash)) + expect_true(file.exists(x$file$path)) + expect_false(is.na(x$file$hash)) path <- file.path("_targets", "objects", "abc") expect_equal(readRDS(path), "123") expect_equal(target_read_value(x)$object, "123") @@ -32,9 +32,11 @@ tar_test("does not inherit from tar_external", { }) tar_test("store_row_path()", { - store <- tar_target(x, "x_value", format = "rds")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "rds") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_stem.R b/tests/testthat/test-class_stem.R index 488959a7..5d2afbe8 100644 --- a/tests/testthat/test-class_stem.R +++ b/tests/testthat/test-class_stem.R @@ -7,7 +7,7 @@ tar_test("target_load_value()", { x <- target_init(name = "abc", expr = quote(2L), format = "rds") tmp <- tempfile() saveRDS("abc", tmp) - file <- x$store$file + file <- x$file file$path <- tmp pipeline <- pipeline_init(list(x)) expect_equal(counter_get_names(pipeline$loaded), character(0)) diff --git a/tests/testthat/test-class_store.R b/tests/testthat/test-class_store.R index db7bfc2d..6d7324a9 100644 --- a/tests/testthat/test-class_store.R +++ b/tests/testthat/test-class_store.R @@ -3,16 +3,15 @@ tar_test("store_wait_correct_hash()", { file <- file_init(path = tmp) writeLines("lines", tmp) store <- store_init() - store$file <- file store$resources <- tar_resources( network = suppressWarnings(tar_resources_network(max_tries = 1L)) ) expect_error( - store_wait_correct_hash(store), + store_wait_correct_hash(store, file), class = "tar_condition_expire" ) file_update_hash(file) - expect_silent(store_wait_correct_hash(store)) + expect_silent(store_wait_correct_hash(store, file)) }) tar_test("default serialization/unserialization methods", { diff --git a/tests/testthat/test-class_store_file.R b/tests/testthat/test-class_store_file.R index 2823ce62..efb68825 100644 --- a/tests/testthat/test-class_store_file.R +++ b/tests/testthat/test-class_store_file.R @@ -11,20 +11,20 @@ tar_test("dynamic files work", { file } builder_update_build(x, envir) - expect_equal(x$store$file$path, character(0)) - expect_true(is.na(x$store$file$hash)) + expect_equal(x$file$path, character(0)) + expect_true(is.na(x$file$hash)) builder_update_paths(x, path_store_default()) - expect_true(file.exists(x$store$file$path)) - expect_true(nzchar(x$store$file$path)) - expect_false(is.na(x$store$file$hash)) + expect_true(file.exists(x$file$path)) + expect_true(nzchar(x$file$path)) + expect_false(is.na(x$file$hash)) expect_silent(store_validate(x$store)) - expect_true(file.exists(x$store$file$path)) - expect_false(is.na(x$store$file$hash)) + expect_true(file.exists(x$file$path)) + expect_false(is.na(x$file$hash)) builder_update_object(x) expect_false(file.exists(file.path("_targets", "objects", "abc"))) expect_equal(readLines(x$value$object), "lines") out <- target_read_value(x)$object - exp <- x$store$file$path + exp <- x$file$path expect_equal(out, exp) }) @@ -57,9 +57,11 @@ tar_test("inherits from tar_external", { }) tar_test("store_row_path()", { - store <- tar_target(x, "x_value", format = "file")$store - store$file$path <- "path" - expect_equal(store_row_path(store), "path") + target <- tar_target(x, "x_value", format = "file") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), "path") }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-class_target.R b/tests/testthat/test-class_target.R index fdf5866f..bed8278c 100644 --- a/tests/testthat/test-class_target.R +++ b/tests/testthat/test-class_target.R @@ -83,7 +83,7 @@ tar_test("target_ensure_value() loads values", { x <- target_init(name = "abc", expr = quote(2L), format = "rds") tmp <- tempfile() saveRDS("abc", tmp) - file <- x$store$file + file <- x$file file$path <- tmp pipeline <- pipeline_init(list(x)) for (index in seq_len(2)) { @@ -99,7 +99,7 @@ tar_test("target_ensure_dep()", { pipeline <- pipeline_init(list(x, y)) tmp <- tempfile() saveRDS("value", tmp) - file <- y$store$file + file <- y$file file$path <- tmp expect_null(y$value$object) for (index in seq_len(2)) { diff --git a/tests/testthat/test-class_torch.R b/tests/testthat/test-class_torch.R index 4a9d77a9..efcca57e 100644 --- a/tests/testthat/test-class_torch.R +++ b/tests/testthat/test-class_torch.R @@ -74,9 +74,11 @@ tar_test("does not inherit from tar_external", { }) tar_test("store_row_path()", { - store <- tar_target(x, "x_value", format = "torch")$store - store$file$path <- "path" - expect_equal(store_row_path(store), NA_character_) + target <- tar_target(x, "x_value", format = "torch") + store <- target$store + file <- target$file + file$path <- "path" + expect_equal(store_row_path(store, file), NA_character_) }) tar_test("store_path_from_record()", { diff --git a/tests/testthat/test-tar_path.R b/tests/testthat/test-tar_path.R index dbd0567d..40c98fb0 100644 --- a/tests/testthat/test-tar_path.R +++ b/tests/testthat/test-tar_path.R @@ -81,7 +81,7 @@ tar_test("tar_path() returns stage for cloud formats", { skip_on_os("windows") x <- tar_target(x, 1, format = "parquet", repository = "aws") store_update_stage_early(x$store, x$settings$name, path_store_default()) - dir <- dirname(x$store$file$stage) + dir <- dirname(x$file$stage) unlink(dir, recursive = TRUE) on.exit(tar_runtime$target <- NULL) on.exit(unlink(dir, recursive = TRUE), add = TRUE) @@ -91,7 +91,7 @@ tar_test("tar_path() returns stage for cloud formats", { out <- suppressWarnings(tar_path(create_dir = TRUE)) expect_true(file.exists(dirname(out))) expect_equal(dirname(out), file.path(path_scratch_dir_network())) - expect_equal(out, x$store$file$stage) + expect_equal(out, x$file$stage) }) tar_test("tar_path() with alternative data store in tar_make()", { diff --git a/tests/testthat/test-tar_path_target.R b/tests/testthat/test-tar_path_target.R index 90463121..844ae7ac 100644 --- a/tests/testthat/test-tar_path_target.R +++ b/tests/testthat/test-tar_path_target.R @@ -70,7 +70,7 @@ tar_test("tar_path_target() returns stage for cloud formats", { skip_on_os("windows") x <- tar_target(x, 1, format = "parquet", repository = "aws") store_update_stage_early(x$store, x$settings$name, path_store_default()) - dir <- dirname(x$store$file$stage) + dir <- dirname(x$file$stage) unlink(dir, recursive = TRUE) on.exit(tar_runtime$target) on.exit(unlink(dir, recursive = TRUE), add = TRUE) @@ -80,7 +80,7 @@ tar_test("tar_path_target() returns stage for cloud formats", { out <- tar_path_target(create_dir = TRUE) expect_true(file.exists(dirname(out))) expect_equal(dirname(out), file.path(path_scratch_dir_network())) - expect_equal(out, x$store$file$stage) + expect_equal(out, x$file$stage) }) tar_test("tar_path_target() with alternative data store in tar_make()", {