forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
have_succeeded.go
32 lines (25 loc) · 865 Bytes
/
have_succeeded.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package matchers
import (
"fmt"
testcmd "code.cloudfoundry.org/cli/util/testhelpers/commands"
"github.com/onsi/gomega"
)
type haveSucceededMatcher struct{}
func HaveSucceeded() gomega.OmegaMatcher {
return haveSucceededMatcher{}
}
func (matcher haveSucceededMatcher) Match(actual interface{}) (bool, error) {
switch actual.(type) {
case testcmd.RunCommandResult:
result := actual.(testcmd.RunCommandResult)
return result == testcmd.RunCommandResultSuccess, nil
default:
return false, fmt.Errorf("Expected actual value to be an enum, but it was a %T", actual)
}
}
func (matcher haveSucceededMatcher) FailureMessage(_ interface{}) string {
return "Expected command to have succeeded but it did not"
}
func (matcher haveSucceededMatcher) NegatedFailureMessage(_ interface{}) string {
return "Expected command to have not succeeded but it did"
}