@@ -121,9 +121,13 @@ local({
121121})
122122
123123local({
124- x = as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , x_value = 10L ))
125- y = as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 5L , y_value = 20L ))
126- print(epix_merge(x ,y , sync = " na" ))
124+ x = as_epi_archive(
125+ tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , x_value = 10L ),
126+ versions_end = 3L
127+ )
128+ y = as_epi_archive(
129+ tibble :: tibble(geo_value = 1L , time_value = 1L , version = 5L , y_value = 20L )
130+ )
127131 test_that(' epix_merge forbids on sync default or "forbid"' , {
128132 expect_error(epix_merge(x ,y ),
129133 class = " epiprocess__epix_merge_unresolved_sync" )
@@ -136,8 +140,10 @@ local({
136140 as_epi_archive(tibble :: tribble(
137141 ~ geo_value , ~ time_value , ~ version , ~ x_value , ~ y_value ,
138142 1L , 1L , 1L , 10L , NA_integer_ , # x updated, y not observed yet
139- 1L , 1L , 2L , NA_integer_ , NA_integer_ , # NA-ing out x, y not observed yet
143+ 1L , 1L , 4L , NA_integer_ , NA_integer_ , # NA-ing out x, y not observed yet
140144 1L , 1L , 5L , NA_integer_ , 20L , # x still NA, y updated
145+ # (we should not have a y vals -> NA update here; version 5 should be
146+ # the `versions_end` of the result)
141147 ), clobberable_versions_start = 1L )
142148 )
143149 })
@@ -151,6 +157,16 @@ local({
151157 ), clobberable_versions_start = 1L )
152158 )
153159 })
160+ test_that(' epix_merge sync="truncate" works' , {
161+ expect_equal(
162+ epix_merge(x ,y , sync = " truncate" ),
163+ as_epi_archive(tibble :: tribble(
164+ ~ geo_value , ~ time_value , ~ version , ~ x_value , ~ y_value ,
165+ 1L , 1L , 1L , 10L , NA_integer_ , # x updated, y not observed yet
166+ # y's update beyond x's last update has been truncated
167+ ), clobberable_versions_start = 1L , versions_end = 3L )
168+ )
169+ })
154170 x_no_conflict = as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , x_value = 10L ))
155171 y_no_conflict = as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , y_value = 20L ))
156172 xy_no_conflict_expected = as_epi_archive(tibble :: tribble(
@@ -178,6 +194,12 @@ local({
178194 xy_no_conflict_expected
179195 )
180196 })
197+ test_that(' epix_merge sync="truncate" on no-conflict works' , {
198+ expect_equal(
199+ epix_merge(x_no_conflict , y_no_conflict , sync = " truncate" ),
200+ xy_no_conflict_expected
201+ )
202+ })
181203})
182204
183205
0 commit comments