Skip to content

Commit efc1985

Browse files
committed
unit test
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 794966e commit efc1985

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,25 @@ void filteringUpdateFallsBackToMapperWhenNoPrimaryToSecondaryIndex() {
780780
verify(eventHandlerMock, times(1)).handleEvent(any());
781781
}
782782

783+
@Test
784+
void skipsEventFilteringWhenResourceVersionIsNull() {
785+
// Without a resourceVersion there is nothing to correlate own-write echoes against, so
786+
// event filtering is bypassed: the update is applied and cached directly, no filter window
787+
// is opened and no event is propagated through handleEvent.
788+
var resourceToUpdate = testDeployment();
789+
resourceToUpdate.getMetadata().setResourceVersion(null);
790+
var updated = deploymentWithResourceVersion(3);
791+
792+
var result =
793+
informerEventSource.eventFilteringUpdateAndCacheResource(resourceToUpdate, r -> updated);
794+
795+
assertThat(result).isSameAs(updated);
796+
verify(temporaryResourceCache, times(1)).putResource(updated);
797+
verify(temporaryResourceCache, never()).startEventFilteringModify(any());
798+
verify(temporaryResourceCache, never()).doneEventFilterModify(any());
799+
verify(eventHandlerMock, never()).handleEvent(any());
800+
}
801+
783802
private PrimaryToSecondaryIndex<Deployment> injectIndexMock() throws Exception {
784803
@SuppressWarnings("unchecked")
785804
PrimaryToSecondaryIndex<Deployment> indexMock = mock(PrimaryToSecondaryIndex.class);

0 commit comments

Comments
 (0)