Improving the error messages in the Operator Test
Closes #31598 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
parent
6d404b86c9
commit
28a27c9148
1 changed files with 12 additions and 4 deletions
|
@ -54,15 +54,23 @@ public final class CRAssert {
|
||||||
|
|
||||||
public static ObjectAssert<KeycloakStatusCondition> assertKeycloakStatusCondition(KeycloakStatus kcStatus, String condition, Boolean status, String containedMessage, Long observedGeneration) {
|
public static ObjectAssert<KeycloakStatusCondition> assertKeycloakStatusCondition(KeycloakStatus kcStatus, String condition, Boolean status, String containedMessage, Long observedGeneration) {
|
||||||
KeycloakStatusCondition statusCondition = kcStatus.findCondition(condition).orElseThrow();
|
KeycloakStatusCondition statusCondition = kcStatus.findCondition(condition).orElseThrow();
|
||||||
assertThat(statusCondition.getStatus()).isEqualTo(status);
|
assertThat(statusCondition.getStatus())
|
||||||
|
.withFailMessage(() -> "found status " + statusCondition + " and expected status " + status)
|
||||||
|
.isEqualTo(status);
|
||||||
if (containedMessage != null) {
|
if (containedMessage != null) {
|
||||||
assertThat(statusCondition.getMessage()).contains(containedMessage);
|
assertThat(statusCondition.getMessage())
|
||||||
|
.withFailMessage(() -> "found status " + statusCondition + " and expected it to contain " + containedMessage)
|
||||||
|
.contains(containedMessage);
|
||||||
}
|
}
|
||||||
if (observedGeneration != null) {
|
if (observedGeneration != null) {
|
||||||
assertThat(statusCondition.getObservedGeneration()).isEqualTo(observedGeneration);
|
assertThat(statusCondition.getObservedGeneration())
|
||||||
|
.withFailMessage(() -> "found status " + statusCondition + " and expected it to contain an observed generation of " + observedGeneration)
|
||||||
|
.isEqualTo(observedGeneration);
|
||||||
}
|
}
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
assertThat(statusCondition.getLastTransitionTime()).isNotNull();
|
assertThat(statusCondition.getLastTransitionTime())
|
||||||
|
.withFailMessage(() -> "found status " + statusCondition + " and expected the last transition time to not be null")
|
||||||
|
.isNotNull();
|
||||||
}
|
}
|
||||||
return assertThat(statusCondition);
|
return assertThat(statusCondition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue