github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+incompatible/integration/shared/isolated/update_service_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gbytes"
     8  	. "github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("update-service command", func() {
    12  	When("an api is targeted, the user is logged in, and an org and space are targeted", func() {
    13  		var (
    14  			orgName string
    15  		)
    16  
    17  		BeforeEach(func() {
    18  			orgName = helpers.NewOrgName()
    19  			var spaceName = helpers.NewSpaceName()
    20  			helpers.SetupCF(orgName, spaceName)
    21  		})
    22  
    23  		AfterEach(func() {
    24  			helpers.QuickDeleteOrg(orgName)
    25  		})
    26  
    27  		When("there is a service instance", func() {
    28  			var (
    29  				service             string
    30  				servicePlan         string
    31  				broker              helpers.ServiceBroker
    32  				serviceInstanceName string
    33  				username            string
    34  			)
    35  
    36  			BeforeEach(func() {
    37  				var domain = helpers.DefaultSharedDomain()
    38  				service = helpers.PrefixedRandomName("SERVICE")
    39  				servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN")
    40  				broker = helpers.CreateBroker(domain, service, servicePlan)
    41  
    42  				Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0))
    43  
    44  				serviceInstanceName = helpers.PrefixedRandomName("SI")
    45  				Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName)).Should(Exit(0))
    46  
    47  				username, _ = helpers.GetCredentials()
    48  			})
    49  
    50  			AfterEach(func() {
    51  				Eventually(helpers.CF("delete-service", serviceInstanceName, "-f")).Should(Exit(0))
    52  				broker.Destroy()
    53  			})
    54  
    55  			When("updating to a service plan that does not exist", func() {
    56  				It("displays an informative error message, exits 1", func() {
    57  					session := helpers.CF("update-service", serviceInstanceName, "-p", "non-existing-service-plan")
    58  					Eventually(session).Should(Say("Plan does not exist for the %s service", service))
    59  					Eventually(session).Should(Exit(1))
    60  				})
    61  			})
    62  
    63  			When("updating to the same service plan (no-op)", func() {
    64  				It("displays an informative success message, exits 0", func() {
    65  					session := helpers.CF("update-service", serviceInstanceName, "-p", servicePlan)
    66  					Eventually(session).Should(Say("Updating service instance %s as %s...", serviceInstanceName, username))
    67  					Eventually(session).Should(Say("OK"))
    68  					Eventually(session).Should(Exit(0))
    69  				})
    70  			})
    71  		})
    72  	})
    73  })