Skip to content

Commit 390cbfd

Browse files
committed
fix
Signed-off-by: wind57 <[email protected]>
1 parent 5cc00bd commit 390cbfd

File tree

3 files changed

+19
-32
lines changed

3 files changed

+19
-32
lines changed

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ void testSecretDataByLabelsThreeSecretsFound() {
199199

200200
MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByLabels(client, "spring-k8s",
201201
Map.of("tag", "fit", "color", "blue"), new MockEnvironment());
202-
Assertions.assertThat(result.names()).contains("blue-circle-secret");
203-
Assertions.assertThat(result.names()).contains("blue-square-secret");
202+
Assertions.assertThat(result.names()).containsExactlyInAnyOrder("blue-circle-secret", "blue-square-secret");
204203

205204
@SuppressWarnings("unchecked")
206205
Map<String, Object> dataBlueSecret = (Map<String, Object>) result.data().get("blue-circle-secret");
@@ -210,10 +209,6 @@ void testSecretDataByLabelsThreeSecretsFound() {
210209
Map<String, Object> dataSquareSecret = (Map<String, Object>) result.data().get("blue-square-secret");
211210
Assertions.assertThat(dataSquareSecret).containsExactlyInAnyOrderEntriesOf(Map.of("two", "2"));
212211

213-
@SuppressWarnings("unchecked")
214-
Map<String, Object> dataSquareSecretK8s = (Map<String, Object>) result.data().get("blue-square-secret-k8s");
215-
Assertions.assertThat(dataSquareSecretK8s).containsExactlyInAnyOrderEntriesOf(Map.of("four", "4"));
216-
217212
}
218213

219214
// secret "my-secret" is deployed; we search for it by name and do not find it.

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledConfigMapContextToSourceDataProviderTests.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,10 @@ void searchWithLabelsOneConfigMapFound() {
376376
}
377377

378378
/**
379-
* <<<<<<< HEAD ======= two configmaps are deployed: "color-configmap" with label:
380-
* "{color:blue}" and "color-configmap-k8s" with label: "{color:red}". We search by
381-
* "{color:blue}" and find one configmap. Since profiles are enabled, we will also be
382-
* reading "color-configmap-k8s", even if its labels do not match provided ones.
379+
* two configmaps are deployed: "color-configmap" with label: "{color:blue}" and
380+
* "color-configmap-k8s" with label: "{color:red}". We search by "{color:blue}" and
381+
* find one configmap. Since profiles are enabled, we will also be reading
382+
* "color-configmap-k8s", even if its labels do not match provided ones.
383383
*/
384384
@Test
385385
void searchWithLabelsOneConfigMapFoundAndOneFromProfileFound() {
@@ -409,15 +409,14 @@ void searchWithLabelsOneConfigMapFoundAndOneFromProfileFound() {
409409
Fabric8ContextToSourceData data = new LabeledConfigMapContextToSourceDataProvider().get();
410410
SourceData sourceData = data.apply(context);
411411

412-
assertThat(sourceData.sourceData().size()).isEqualTo(2);
412+
assertThat(sourceData.sourceData().size()).isEqualTo(1);
413413
assertThat(sourceData.sourceData().get("color-configmap.one")).isEqualTo("1");
414-
assertThat(sourceData.sourceData().get("color-configmap-k8s.two")).isEqualTo("2");
415-
assertThat(sourceData.sourceName()).isEqualTo("configmap.color-configmap.color-configmap-k8s.default");
414+
assertThat(sourceData.sourceName()).isEqualTo("configmap.color-configmap.default");
416415

417416
}
418417

419418
/**
420-
* >>>>>>> main <pre>
419+
* <pre>
421420
* - configmap "color-configmap" with label "{color:blue}"
422421
* - configmap "shape-configmap" with labels "{color:blue, shape:round}"
423422
* - configmap "no-fit" with labels "{tag:no-fit}"
@@ -477,15 +476,12 @@ void searchWithLabelsTwoConfigMapsFound() {
477476
Fabric8ContextToSourceData data = new LabeledConfigMapContextToSourceDataProvider().get();
478477
SourceData sourceData = data.apply(context);
479478

480-
assertThat(sourceData.sourceData().size()).isEqualTo(4);
479+
assertThat(sourceData.sourceData().size()).isEqualTo(2);
481480

482481
assertThat(sourceData.sourceData().get("color-configmap.one")).isEqualTo("1");
483482
assertThat(sourceData.sourceData().get("shape-configmap.two")).isEqualTo("2");
484-
assertThat(sourceData.sourceData().get("color-configmap-k8s.four")).isEqualTo("4");
485-
assertThat(sourceData.sourceData().get("shape-configmap-k8s.five")).isEqualTo("5");
486483

487-
assertThat(sourceData.sourceName())
488-
.isEqualTo("configmap.color-configmap.color-configmap-k8s.shape-configmap.shape-configmap-k8s.default");
484+
assertThat(sourceData.sourceName()).isEqualTo("configmap.color-configmap.shape-configmap.default");
489485

490486
}
491487

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledSecretContextToSourceDataProviderTests.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,10 @@ void searchWithLabelsOneSecretFound() {
376376
}
377377

378378
/**
379-
* <<<<<<< HEAD ======= two secrets are deployed: secret "color-secret" with label:
380-
* "{color:blue}" and "color-secret-k8s" with label: "{color:red}". We search by
381-
* "{color:blue}" and find one secret. Since profiles are enabled, we will also be
382-
* reading "color-secret-k8s", even if its labels do not match provided ones.
379+
* two secrets are deployed: secret "color-secret" with label: "{color:blue}" and
380+
* "color-secret-k8s" with label: "{color:red}". We search by "{color:blue}" and find
381+
* one secret. Since profiles are enabled, we will also be reading "color-secret-k8s",
382+
* even if its labels do not match provided ones.
383383
*/
384384
@Test
385385
void searchWithLabelsOneSecretFoundAndOneFromProfileFound() {
@@ -409,15 +409,14 @@ void searchWithLabelsOneSecretFoundAndOneFromProfileFound() {
409409
Fabric8ContextToSourceData data = new LabeledSecretContextToSourceDataProvider().get();
410410
SourceData sourceData = data.apply(context);
411411

412-
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(2);
412+
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(1);
413413
Assertions.assertThat(sourceData.sourceData().get("color-secret.one")).isEqualTo("1");
414-
Assertions.assertThat(sourceData.sourceData().get("color-secret-k8s.two")).isEqualTo("2");
415-
Assertions.assertThat(sourceData.sourceName()).isEqualTo("secret.color-secret.color-secret-k8s.default");
414+
Assertions.assertThat(sourceData.sourceName()).isEqualTo("secret.color-secret.default");
416415

417416
}
418417

419418
/**
420-
* >>>>>>> main <pre>
419+
* <pre>
421420
* - secret "color-secret" with label "{color:blue}"
422421
* - secret "shape-secret" with labels "{color:blue, shape:round}"
423422
* - secret "no-fit" with labels "{tag:no-fit}"
@@ -477,14 +476,11 @@ void searchWithLabelsTwoSecretsFound() {
477476
Fabric8ContextToSourceData data = new LabeledSecretContextToSourceDataProvider().get();
478477
SourceData sourceData = data.apply(context);
479478

480-
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(4);
479+
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(2);
481480
assertThat(sourceData.sourceData().get("color-secret.one")).isEqualTo("1");
482481
assertThat(sourceData.sourceData().get("shape-secret.two")).isEqualTo("2");
483-
assertThat(sourceData.sourceData().get("color-secret-k8s.four")).isEqualTo("4");
484-
assertThat(sourceData.sourceData().get("shape-secret-k8s.five")).isEqualTo("5");
485482

486-
assertThat(sourceData.sourceName())
487-
.isEqualTo("secret.color-secret.color-secret-k8s.shape-secret.shape-secret-k8s.default");
483+
assertThat(sourceData.sourceName()).isEqualTo("secret.color-secret.shape-secret.default");
488484

489485
}
490486

0 commit comments

Comments
 (0)