github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/actor/actionerror/enrich_api_errors_test.go (about)

     1  package actionerror_test
     2  
     3  import (
     4  	"errors"
     5  
     6  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
     7  
     8  	"code.cloudfoundry.org/cli/actor/actionerror"
     9  
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  )
    13  
    14  var _ = Describe("service access actions", func() {
    15  	It("enriches a ServiceOfferingNameAmbiguityError", func() {
    16  		err := actionerror.EnrichAPIErrors(ccerror.ServiceOfferingNameAmbiguityError{
    17  			ServiceOfferingName: "foo",
    18  			ServiceBrokerNames:  []string{"bar", "baz", "qux"},
    19  		})
    20  
    21  		Expect(err).To(MatchError("Service 'foo' is provided by multiple service brokers: bar, baz, qux\nSpecify a broker by using the '-b' flag."))
    22  	})
    23  
    24  	It("handles nil", func() {
    25  		Expect(actionerror.EnrichAPIErrors(nil)).To(BeNil())
    26  	})
    27  
    28  	It("passes though other errors", func() {
    29  		Expect(actionerror.EnrichAPIErrors(errors.New("foo"))).To(MatchError(errors.New("foo")))
    30  	})
    31  })