@@ -121,9 +121,13 @@ local({
121
121
})
122
122
123
123
local({
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
+ )
127
131
test_that(' epix_merge forbids on sync default or "forbid"' , {
128
132
expect_error(epix_merge(x ,y ),
129
133
class = " epiprocess__epix_merge_unresolved_sync" )
@@ -136,8 +140,10 @@ local({
136
140
as_epi_archive(tibble :: tribble(
137
141
~ geo_value , ~ time_value , ~ version , ~ x_value , ~ y_value ,
138
142
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
140
144
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)
141
147
), clobberable_versions_start = 1L )
142
148
)
143
149
})
@@ -151,6 +157,16 @@ local({
151
157
), clobberable_versions_start = 1L )
152
158
)
153
159
})
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
+ })
154
170
x_no_conflict = as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , x_value = 10L ))
155
171
y_no_conflict = as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , y_value = 20L ))
156
172
xy_no_conflict_expected = as_epi_archive(tibble :: tribble(
@@ -178,6 +194,12 @@ local({
178
194
xy_no_conflict_expected
179
195
)
180
196
})
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
+ })
181
203
})
182
204
183
205
0 commit comments