Skip to content

Improve failure messages in operator-developer-e2e condition comparison #483

@m1kola

Description

@m1kola

As shown in #481 today if there is a failure in operator-developer-e2e due to unexpected condition we get a message like this:

Status conditions for the operator plain-operator for the version 0.2.0 is not as expected:Expected status: True, but got: False

We should include condition message when failing test due to unexpected condition as it usually contains useful information.

Relevant code:

func checkConditionEquals(actualCond, expectedCond *metav1.Condition) error {
if actualCond == nil {
return fmt.Errorf("Expected condition %s to not be nil", expectedCond.Type)
}
if actualCond.Status != expectedCond.Status {
return fmt.Errorf("Expected status: %s, but got: %s", expectedCond.Status, actualCond.Status)
}
if actualCond.Reason != expectedCond.Reason {
return fmt.Errorf("Expected reason: %s but got: %s", expectedCond.Reason, actualCond.Reason)
}
if !strings.Contains(actualCond.Message, expectedCond.Message) {
return fmt.Errorf("Expected message: %s but got: %s", expectedCond.Message, actualCond.Message)
}
return nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions