From 7b2596ee7cc82a8251c29084c7a193b59f0706e7 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Wed, 23 Oct 2024 14:37:00 +0100 Subject: [PATCH] Update metadata on push --- R/location.R | 1 + tests/testthat/test-location-path.R | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/R/location.R b/R/location.R index 6c41d7fa..05b83790 100644 --- a/R/location.R +++ b/R/location.R @@ -501,6 +501,7 @@ orderly_location_push <- function(expr, location, name = NULL, dry_run = FALSE, driver <- location_driver(location_name, root) location_push_files(plan$files, driver, root) location_push_metadata(plan$packet_id, driver, root) + orderly_location_pull_metadata(location_name, root) } } diff --git a/tests/testthat/test-location-path.R b/tests/testthat/test-location-path.R index 6f7acafc..9cb169ad 100644 --- a/tests/testthat/test-location-path.R +++ b/tests/testthat/test-location-path.R @@ -191,8 +191,8 @@ test_that("Import complete tree via push into server", { expect_equal(idx_s$metadata, idx_c$metadata) expect_equal(idx_s$unpacked, idx_c$unpacked) - expect_equal(idx_s$location$packet, idx_c$location$packet) - expect_equal(idx_s$location$hash, idx_c$location$hash) + expect_equal(idx_s$location$packet, idx_c$unpacked) + expect_setequal(idx_s$location$hash, idx_c$location$hash) expect_setequal(plan$packet_id, ids) files_used <- lapply(ids, function(id) client$index$metadata(id)$files$hash) @@ -304,8 +304,8 @@ test_that("Push single packet", { expect_equal(idx_s$metadata, idx_c$metadata) expect_equal(idx_s$unpacked, idx_c$unpacked) - expect_equal(idx_s$location$packet, idx_c$location$packet) - expect_equal(idx_s$location$hash, idx_c$location$hash) + expect_equal(idx_s$location$packet, idx_c$unpacked) + expect_setequal(idx_s$location$hash, idx_c$location$hash) expect_equal(plan$packet_id, id) files_used <- lapply(id, function(id) client$index$metadata(id)$files$hash) @@ -407,3 +407,17 @@ test_that("prevent pushing unknown packets", { orderly_location_push("20241023-131946-0260c975", "server", root = client), "Trying to push unknown packet: '20241023-131946-0260c975'") }) + + +test_that("pull metadata after push", { + client <- create_temporary_root() + id1 <- create_random_packet(client, parameters = list(a = 1)) + id2 <- create_random_packet(client, parameters = list(a = 2)) + id3 <- create_random_packet(client, parameters = list(a = 1)) + + server <- create_temporary_root(use_file_store = TRUE, path_archive = NULL) + orderly_location_add_path("server", path = server$path, root = client) + + plan <- orderly_location_push("parameter:a == 1", "server", root = client) + expect_length(orderly_search(location = "server", root = client), 2) +})