From e01efe0bfa5956eb0274f29281c4bc8b5d633971 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Thu, 24 Oct 2024 04:25:41 +0100 Subject: [PATCH] wip --- R/compare.R | 3 +++ tests/testthat/_snaps/compare.md | 20 ++++---------------- tests/testthat/test-compare.R | 12 ++++-------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/R/compare.R b/R/compare.R index 3c84be75..321acbb7 100644 --- a/R/compare.R +++ b/R/compare.R @@ -256,6 +256,9 @@ orderly_comparison_explain <- function(cmp, attributes = NULL, ..., cli::cli_alert_info( "Comparing packets {cmp$target$id} and {cmp$current$id}...") + # All packets we produce have the same attributes. This is really more about + # future-proofing for a time where we may add new ones, and may want to + # compare a packet produced before vs after the new attributes were added. if (any(status == "added")) { cli::cli_alert_info( "The following attributes only exist in packet {cmp$target$id}:") diff --git a/tests/testthat/_snaps/compare.md b/tests/testthat/_snaps/compare.md index 30bb52b8..d135ffb1 100644 --- a/tests/testthat/_snaps/compare.md +++ b/tests/testthat/_snaps/compare.md @@ -143,8 +143,7 @@ Message i Comparing packets 19700101-000000-00000001 and 19700101-000000-00000002... i The following files exist in both packets but have different contents: - * data.R - * data.txt + * data.rds i Use `orderly_comparison_explain(result, "files", verbose = TRUE)` to compare the files' contents. --- @@ -154,18 +153,7 @@ Message i Comparing packets 19700101-000000-00000001 and 19700101-000000-00000002... i Looking for suitable files already on disk - i Need to fetch 2 files (38 B) from 1 location - \ Fetching file 1/2 (32 B) from 'there' | ETA: 0s [7ms] - v Fetched 2 files (38 B) from 'there' in 79ms. - - < 19700101-000000-00000001/data.R - > 19700101-000000-00000002/data.R - @@ 1 / 1 @@ - < writeLines("Hello", "data.txt") - > writeLines("World", "data.txt") - < 19700101-000000-00000001/data.txt - > 19700101-000000-00000002/data.txt - @@ 1 / 1 @@ - < Hello - > World + i Need to fetch 1 file (115 B) from 1 location + ! The following files differ across packets, but could not be compared as their content is binary: + * data.rds diff --git a/tests/testthat/test-compare.R b/tests/testthat/test-compare.R index 0d70e944..e3941111 100644 --- a/tests/testthat/test-compare.R +++ b/tests/testthat/test-compare.R @@ -108,8 +108,8 @@ test_that("Can compare packets from remote", { here <- create_temporary_root() there <- create_temporary_root() - id1 <- orderly_run_snippet(here, "data", writeLines("Hello", "data.txt")) - id2 <- orderly_run_snippet(there, "data", writeLines("World", "data.txt")) + id1 <- create_random_packet(here) + id2 <- create_random_packet(there) orderly_location_add("there", "path", list(path = there$path), root = here) @@ -117,12 +117,8 @@ test_that("Can compare packets from remote", { orderly_compare_packets(id1, id2, root = here), "Packet .* not found in outpack index") - withr::local_options(orderly.quiet = FALSE) - - suppressMessages(expect_message({ - result <- orderly_compare_packets(id1, id2, root = here, - pull_metadata = TRUE) - }, "Fetching metadata from 1 location: 'there'")) + result <- orderly_compare_packets(id1, id2, root = here, + pull_metadata = TRUE) expect_snapshot(orderly_comparison_explain(result, "files"), transform = scrub_packets(id1, id2))