Skip to content

Commit 6208e43

Browse files
committed
updating tests
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
1 parent 1501a6e commit 6208e43

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/TemporaryPrimaryResourceCacheTest.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.javaoperatorsdk.operator.processing.event.source.informer.TemporaryResourceCache.EventHandling;
3232

3333
import static org.assertj.core.api.Assertions.assertThat;
34+
import static org.junit.jupiter.api.Assertions.assertTrue;
3435

3536
class TemporaryPrimaryResourceCacheTest {
3637

@@ -179,7 +180,7 @@ void putBeforeEventWithEventFiltering() {
179180
}
180181

181182
@Test
182-
void putAfterEventWithEventFiltering() {
183+
void putAfterEventWithEventFilteringNoPost() {
183184
var testResource = testResource();
184185

185186
// first ensure an event is not known
@@ -195,7 +196,29 @@ void putAfterEventWithEventFiltering() {
195196
// the result is deferred
196197
assertThat(result).isEqualTo(EventHandling.DEFER);
197198
temporaryResourceCache.putResource(nextResource);
198-
temporaryResourceCache.doneEventFilterModify(resourceId, "3");
199+
var postEvent = temporaryResourceCache.doneEventFilterModify(resourceId, "3");
200+
201+
// there is no post event because the done call claimed responsibility for rv 3
202+
assertTrue(postEvent.isEmpty());
203+
}
204+
205+
@Test
206+
void putAfterEventWithEventFilteringWithPost() {
207+
var testResource = testResource();
208+
var resourceId = ResourceID.fromResource(testResource);
209+
temporaryResourceCache.startEventFilteringModify(resourceId);
210+
211+
// this should be a corner case - watch had a hard reset since the start of the
212+
// of the update operation, such that 4 rv event is seen prior to the update
213+
// completing with the 3 rv.
214+
var nextResource = testResource();
215+
nextResource.getMetadata().setResourceVersion("4");
216+
var result = temporaryResourceCache.onAddOrUpdateEvent(nextResource);
217+
assertThat(result).isEqualTo(EventHandling.DEFER);
218+
219+
var postEvent = temporaryResourceCache.doneEventFilterModify(resourceId, "3");
220+
221+
assertTrue(postEvent.isPresent());
199222
}
200223

201224
@Test

0 commit comments

Comments
 (0)