Skip to content

Commit 5d36a82

Browse files
committed
refactor: more accurate error messages, fix typos/grammar
1 parent 7348cc2 commit 5d36a82

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/GenericKubernetesResourceMatcherTest.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void matchesTrivialCases() {
4545
void matchesAdditiveOnlyChanges() {
4646
actual.getSpec().getTemplate().getMetadata().getLabels().put("new-key", "val");
4747
assertThat(matcher.match(actual, null, context).matched())
48-
.withFailMessage("Additive changes should be ok")
48+
.withFailMessage("Additive changes should be not cause a mismatch by default")
4949
.isTrue();
5050
}
5151

@@ -54,44 +54,44 @@ void matchesWithStrongSpecEquality() {
5454
actual.getSpec().getTemplate().getMetadata().getLabels().put("new-key", "val");
5555
assertThat(GenericKubernetesResourceMatcher
5656
.match(dependentResource, actual, null, context, true, true).matched())
57-
.withFailMessage("Strong equality does not ignore additive changes on spec")
57+
.withFailMessage("Adding values should fail matching when strong equality is required")
5858
.isFalse();
5959
}
6060

6161
@Test
62-
void notMatchesRemovedValues() {
62+
void doesNotMatchRemovedValues() {
6363
actual = createDeployment();
6464
assertThat(matcher.match(actual, createPrimary("removed"), context).matched())
65-
.withFailMessage("Removed value should not be ok")
65+
.withFailMessage("Removing values in metadata should lead to a mismatch")
6666
.isFalse();
6767
}
6868

6969
@Test
70-
void notMatchesChangedValues() {
70+
void doesNotMatchChangedValues() {
7171
actual = createDeployment();
7272
actual.getSpec().setReplicas(2);
7373
assertThat(matcher.match(actual, null, context).matched())
74-
.withFailMessage("Changed values are not ok")
74+
.withFailMessage("Should not have matched because values have changed")
7575
.isFalse();
7676
}
7777

7878
@Test
79-
void notMatchesIgnoredPaths() {
79+
void doesNotMatchIgnoredPaths() {
8080
actual = createDeployment();
8181
actual.getSpec().setReplicas(2);
8282
assertThat(GenericKubernetesResourceMatcher
8383
.match(dependentResource, actual, null, context, false, "/spec/replicas").matched())
84-
.withFailMessage("Ignored paths are not matched")
84+
.withFailMessage("Should not have compared ignored paths")
8585
.isTrue();
8686
}
8787

8888
@Test
8989
void ignoresWholeSubPath() {
9090
actual = createDeployment();
91-
actual.getSpec().getTemplate().getMetadata().getLabels().put("additionak-key", "val");
91+
actual.getSpec().getTemplate().getMetadata().getLabels().put("additional-key", "val");
9292
assertThat(GenericKubernetesResourceMatcher
9393
.match(dependentResource, actual, null, context, false, "/spec/template").matched())
94-
.withFailMessage("Ignored sub-paths are not matched")
94+
.withFailMessage("Should match when only changes impact ignored sub-paths")
9595
.isTrue();
9696
}
9797

@@ -114,7 +114,7 @@ void matchesMetadata() {
114114

115115
assertThat(GenericKubernetesResourceMatcher
116116
.match(dependentResource, actual, null, context, true, false).matched())
117-
.withFailMessage("Non strong equality on labels and annotations")
117+
.withFailMessage("Should match when strong equality is not considered and only additive changes are made")
118118
.isTrue();
119119

120120
}

0 commit comments

Comments
 (0)