From 04e48b5c782d068b15ab7b71132e15aa337df3ee Mon Sep 17 00:00:00 2001 From: Amirouche Date: Fri, 15 Mar 2024 16:48:50 +0100 Subject: [PATCH] Adapt tests to the new NameEnricher behaviour --- .../enricher/generic/NameEnricherTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/NameEnricherTest.java b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/NameEnricherTest.java index d935ac80ba..1d9577ff26 100644 --- a/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/NameEnricherTest.java +++ b/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/NameEnricherTest.java @@ -118,7 +118,7 @@ void create_withAlreadyExistingName_shouldKeepExistingName() { } @Test - void create_withCustomNameAndAlreadyExistingName_shouldOverrideExistingName() { + void create_withCustomNameAndAlreadyExistingName_shouldKeepExistingName() { // Given klb = new KubernetesListBuilder(); properties.put("jkube.enricher.jkube-name.name", "custom-name"); @@ -128,6 +128,20 @@ void create_withCustomNameAndAlreadyExistingName_shouldOverrideExistingName() { // Then assertThat(klb.build().getItems()) .singleElement() - .hasFieldOrPropertyWithValue("metadata.name", "custom-name"); + .hasFieldOrPropertyWithValue("metadata.name", "existing-name"); + } + + @Test + void create_withoutName_shouldSetGivenCustomName() { + // Given + klb = new KubernetesListBuilder(); + properties.put("jkube.enricher.jkube-name.name", "custom-name"); + // When + klb.addToItems(new ServiceBuilder().withNewMetadata().endMetadata().build()); + new NameEnricher(context).create(PlatformMode.kubernetes, klb); + // Then + assertThat(klb.build().getItems()) + .singleElement() + .hasFieldOrPropertyWithValue("metadata.name", "custom-name"); } }