Add more convenience mattchers to the phase matcher
Check for two common cases without extra writing the phase:
```
Expect(ThisDV(dv)).To(HaveSucceeded())
Expect(ThisVMI(vmi)).To(BeRunning())
```
@@ -11,6 +11,18 @@ import (
"kubevirt.io/kubevirt/tests/framework/matcher/helper"
)
+func BeRunning() types.GomegaMatcher {
+ return phaseMatcher{
+ expectedPhase: "Running",
+ }
+}
+
+func HaveSucceeded() types.GomegaMatcher {
+ return phaseMatcher{
+ expectedPhase: "Succeeded",
+ }
+}
+
func BeInPhase(phase interface{}) types.GomegaMatcher {
return phaseMatcher{
expectedPhase: phase,
@@ -65,7 +77,7 @@ func (p phaseMatcher) FailureMessage(actual interface{}) (message string) {
if err != nil {
return err.Error()
}
- return fmt.Sprintf("expected phase is %v but got %v", expectedPhase, phase)
+ return fmt.Sprintf("expected phase is '%v' but got '%v'", expectedPhase, phase)
}
func (p phaseMatcher) NegatedFailureMessage(actual interface{}) (message string) {
@@ -80,7 +92,7 @@ func (p phaseMatcher) NegatedFailureMessage(actual interface{}) (message string)
if err != nil {
return err.Error()
}
- return fmt.Sprintf("expected phase %v to not match %v", expectedPhase, phase)
+ return fmt.Sprintf("expected phase '%v' to not match '%v'", expectedPhase, phase)
}
func getCurrentPhase(actual interface{}) (string, error) {
