Skip to content

Commit ecf4caf

Browse files
committed
unit test for ghost resource handling
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent e09e68a commit ecf4caf

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,24 @@ void byIndexStreamWithStrongConsistencyKeepsResourceWhenTempCacheHasOlderVersion
651651
assertThat(result).containsExactly(original);
652652
}
653653

654+
@Test
655+
void listWithStrongConsistencyKeepsAddsGhostResources() {
656+
var resource = testDeployment();
657+
var ghostResource = testDeployment();
658+
ghostResource.getMetadata().setName("ghost");
659+
660+
when(temporaryResourceCache.getResources())
661+
.thenReturn(Map.of(ResourceID.fromResource(ghostResource), ghostResource));
662+
663+
var mim = mock(InformerManager.class);
664+
when(mim.list(nullable(String.class), any())).thenReturn(Stream.of(resource));
665+
doReturn(mim).when(informerEventSource).manager();
666+
667+
var result = informerEventSource.listWithStrongConsistency(null, r -> true).toList();
668+
669+
assertThat(result).containsExactlyInAnyOrder(resource, ghostResource);
670+
}
671+
654672
Deployment testDeployment() {
655673
Deployment deployment = new Deployment();
656674
deployment.setMetadata(new ObjectMeta());

0 commit comments

Comments
 (0)