github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/util/testhelpers/matchers/passed_requirements.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 havePassedRequirementsMatcher struct{}
    11  
    12  func HavePassedRequirements() gomega.OmegaMatcher {
    13  	return havePassedRequirementsMatcher{}
    14  }
    15  
    16  func (matcher havePassedRequirementsMatcher) Match(actual interface{}) (bool, error) {
    17  	switch actual.(type) {
    18  	case bool:
    19  		asBool := actual.(bool)
    20  		return asBool == true, nil
    21  	case testcmd.RunCommandResult:
    22  		result := actual.(testcmd.RunCommandResult)
    23  		return result == testcmd.RunCommandResultSuccess, nil
    24  	default:
    25  		return false, fmt.Errorf("Expected actual value to be a bool or enum, but it was a %T", actual)
    26  	}
    27  }
    28  
    29  func (matcher havePassedRequirementsMatcher) FailureMessage(_ interface{}) string {
    30  	return "Expected command to pass requirements but it did not"
    31  }
    32  
    33  func (matcher havePassedRequirementsMatcher) NegatedFailureMessage(_ interface{}) string {
    34  	return "Expected command to have not passed requirements but it did"
    35  }