github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/command/translatableerror/service_instance_not_shareable_error_test.go (about)

     1  package translatableerror_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/command/translatableerror"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  )
     8  
     9  var _ = Describe("ServiceInstanceNotShareableError", func() {
    10  	var serviceInstanceNotShareableErr ServiceInstanceNotShareableError
    11  
    12  	BeforeEach(func() {
    13  		serviceInstanceNotShareableErr = ServiceInstanceNotShareableError{}
    14  	})
    15  
    16  	Describe("Error", func() {
    17  		When("feature flag is disabled, and service broker sharing is disabled", func() {
    18  			BeforeEach(func() {
    19  				serviceInstanceNotShareableErr.FeatureFlagEnabled = false
    20  				serviceInstanceNotShareableErr.ServiceBrokerSharingEnabled = false
    21  			})
    22  
    23  			It("returns the appropriate string", func() {
    24  				Expect(serviceInstanceNotShareableErr.Error()).To(Equal(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform. Also, service instance sharing is disabled for this service.`))
    25  			})
    26  		})
    27  
    28  		When("feature flag is enabled, and service broker sharing is disabled", func() {
    29  			BeforeEach(func() {
    30  				serviceInstanceNotShareableErr.FeatureFlagEnabled = true
    31  				serviceInstanceNotShareableErr.ServiceBrokerSharingEnabled = false
    32  			})
    33  
    34  			It("returns the appropriate string", func() {
    35  				Expect(serviceInstanceNotShareableErr.Error()).To(Equal("Service instance sharing is disabled for this service."))
    36  			})
    37  		})
    38  
    39  		When("feature flag is disabled, and service broker sharing is enabled", func() {
    40  			BeforeEach(func() {
    41  				serviceInstanceNotShareableErr.FeatureFlagEnabled = false
    42  				serviceInstanceNotShareableErr.ServiceBrokerSharingEnabled = true
    43  			})
    44  
    45  			It("returns the appropriate string", func() {
    46  				Expect(serviceInstanceNotShareableErr.Error()).To(Equal(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform.`))
    47  			})
    48  		})
    49  
    50  		When("feature flag is enabled, and service broker sharing is enabled", func() {
    51  			BeforeEach(func() {
    52  				serviceInstanceNotShareableErr.FeatureFlagEnabled = true
    53  				serviceInstanceNotShareableErr.ServiceBrokerSharingEnabled = true
    54  			})
    55  
    56  			It("returns unexpected scenario because this error should not be used in this case", func() {
    57  				Expect(serviceInstanceNotShareableErr.Error()).To(Equal("Unexpected ServiceInstanceNotShareableError: service instance is shareable."))
    58  			})
    59  		})
    60  	})
    61  })