github.com/asifdxtreme/cli@v6.1.3-0.20150123051144-9ead8700b4ae+incompatible/testhelpers/matchers/have_succeeded.go (about)

     1  package matchers
     2  
     3  import (
     4  	"github.com/cloudfoundry/cli/cf/errors"
     5  	testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
     6  	"github.com/onsi/gomega"
     7  )
     8  
     9  type haveSucceededMatcher struct{}
    10  
    11  func HaveSucceeded() gomega.OmegaMatcher {
    12  	return haveSucceededMatcher{}
    13  }
    14  
    15  func (matcher haveSucceededMatcher) Match(actual interface{}) (bool, error) {
    16  	switch actual.(type) {
    17  	case testcmd.RunCommandResult:
    18  		result := actual.(testcmd.RunCommandResult)
    19  		return result == testcmd.RunCommandResultSuccess, nil
    20  	default:
    21  		return false, errors.NewWithFmt("Expected actual value to be an enum, but it was a %T", actual)
    22  	}
    23  }
    24  
    25  func (matcher haveSucceededMatcher) FailureMessage(_ interface{}) string {
    26  	return "Expected command to have succeeded but it did not"
    27  }
    28  
    29  func (matcher haveSucceededMatcher) NegatedFailureMessage(_ interface{}) string {
    30  	return "Expected command to have not succeeded but it did"
    31  }