Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Oct 24, 2024
1 parent 8262078 commit e01efe0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
3 changes: 3 additions & 0 deletions R/compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}:")
Expand Down
20 changes: 4 additions & 16 deletions tests/testthat/_snaps/compare.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---
Expand All @@ -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

12 changes: 4 additions & 8 deletions tests/testthat/test-compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,17 @@ 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)

expect_error(
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))
Expand Down

0 comments on commit e01efe0

Please sign in to comment.