github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/util/testhelpers/matchers/have_succeeded.go (about)

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