github.com/loafoe/cli@v7.1.0+incompatible/integration/v7/global/service_command_test.go (about)

     1  package global
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	"code.cloudfoundry.org/cli/integration/helpers/servicebrokerstub"
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  	. "github.com/onsi/gomega/gbytes"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("service command", func() {
    13  
    14  	var (
    15  		serviceInstanceName string
    16  		orgName             string
    17  		sourceSpaceName     string
    18  
    19  		service     string
    20  		servicePlan string
    21  		broker      *servicebrokerstub.ServiceBrokerStub
    22  	)
    23  
    24  	BeforeEach(func() {
    25  		serviceInstanceName = helpers.PrefixedRandomName("SI")
    26  		orgName = helpers.NewOrgName()
    27  		sourceSpaceName = helpers.NewSpaceName()
    28  		helpers.SetupCF(orgName, sourceSpaceName)
    29  
    30  		broker = servicebrokerstub.EnableServiceAccess()
    31  		service = broker.FirstServiceOfferingName()
    32  		servicePlan = broker.FirstServicePlanName()
    33  
    34  		Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName)).Should(Exit(0))
    35  	})
    36  
    37  	AfterEach(func() {
    38  		broker.Forget()
    39  		helpers.QuickDeleteOrg(orgName)
    40  	})
    41  
    42  	Context("service is shared between two spaces", func() {
    43  		var (
    44  			targetSpaceName string
    45  		)
    46  
    47  		BeforeEach(func() {
    48  			targetSpaceName = helpers.NewSpaceName()
    49  			helpers.CreateOrgAndSpace(orgName, targetSpaceName)
    50  			helpers.TargetOrgAndSpace(orgName, sourceSpaceName)
    51  			Eventually(helpers.CF("share-service", serviceInstanceName, "-s", targetSpaceName)).Should(Exit(0))
    52  		})
    53  
    54  		Context("due to global settings of service sharing disabled", func() {
    55  			BeforeEach(func() {
    56  				helpers.DisableFeatureFlag("service_instance_sharing")
    57  			})
    58  
    59  			AfterEach(func() {
    60  				helpers.EnableFeatureFlag("service_instance_sharing")
    61  			})
    62  
    63  			It("should display that the service instance feature flag is disabled", func() {
    64  				session := helpers.CF("service", serviceInstanceName)
    65  				Eventually(session).Should(Say(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform.`))
    66  				Eventually(session).Should(Exit(0))
    67  			})
    68  
    69  			Context("AND service broker does not allow service instance sharing", func() {
    70  				BeforeEach(func() {
    71  					broker.Services[0].Shareable = false
    72  					broker.Configure().Register()
    73  				})
    74  
    75  				It("should display that service instance sharing is disabled for this service (global message)", func() {
    76  					session := helpers.CF("service", serviceInstanceName)
    77  					Eventually(session).Should(Say(`The "service_instance_sharing" feature flag is disabled for this Cloud Foundry platform. Also, service instance sharing is disabled for this service.`))
    78  					Eventually(session).Should(Exit(0))
    79  				})
    80  			})
    81  		})
    82  	})
    83  })