forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passed_requirements.go
35 lines (28 loc) · 1003 Bytes
/
passed_requirements.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
33
34
35
package matchers
import (
"fmt"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
"github.com/onsi/gomega"
)
type havePassedRequirementsMatcher struct{}
func HavePassedRequirements() gomega.OmegaMatcher {
return havePassedRequirementsMatcher{}
}
func (matcher havePassedRequirementsMatcher) Match(actual interface{}) (bool, error) {
switch actual.(type) {
case bool:
asBool := actual.(bool)
return asBool == true, nil
case testcmd.RunCommandResult:
result := actual.(testcmd.RunCommandResult)
return result == testcmd.RunCommandResultSuccess, nil
default:
return false, fmt.Errorf("Expected actual value to be a bool or enum, but it was a %T", actual)
}
}
func (matcher havePassedRequirementsMatcher) FailureMessage(_ interface{}) string {
return "Expected command to pass requirements but it did not"
}
func (matcher havePassedRequirementsMatcher) NegatedFailureMessage(_ interface{}) string {
return "Expected command to have not passed requirements but it did"
}