github.com/wanddynosios/cli@v7.1.0+incompatible/integration/v6/isolated/set_space_quota_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers"
     5  	"code.cloudfoundry.org/cli/integration/helpers"
     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("set-space-quota command", func() {
    13  	var (
    14  		orgName   string
    15  		spaceName string
    16  		quotaName string
    17  	)
    18  	BeforeEach(func() {
    19  		orgName = helpers.NewOrgName()
    20  		spaceName = helpers.NewSpaceName()
    21  
    22  		helpers.SetupCF(orgName, spaceName)
    23  		quotaName = helpers.QuotaName()
    24  		session := helpers.CF("create-space-quota", quotaName)
    25  		Eventually(session).Should(Exit(0))
    26  	})
    27  
    28  	AfterEach(func() {
    29  		helpers.QuickDeleteOrg(orgName)
    30  	})
    31  
    32  	Describe("help", func() {
    33  		When("--help flag is set", func() {
    34  			It("appears in cf help -a", func() {
    35  				session := helpers.CF("help", "-a")
    36  				Eventually(session).Should(Exit(0))
    37  				Expect(session).To(HaveCommandInCategoryWithDescription("set-space-quota", "SPACE ADMIN", "Assign a space quota definition to a space"))
    38  			})
    39  
    40  			It("Displays command usage to output", func() {
    41  				session := helpers.CF("set-space-quota", "--help")
    42  				Eventually(session).Should(Say("NAME:"))
    43  				Eventually(session).Should(Say("set-space-quota - Assign a space quota definition to a space"))
    44  				Eventually(session).Should(Say("USAGE:"))
    45  				Eventually(session).Should(Say(`cf set-space-quota SPACE_NAME SPACE_QUOTA_NAME`))
    46  				Eventually(session).Should(Say("SEE ALSO:"))
    47  				Eventually(session).Should(Say("space, space-quotas, spaces"))
    48  				Eventually(session).Should(Exit(0))
    49  			})
    50  		})
    51  	})
    52  
    53  	When("the environment is not setup correctly", func() {
    54  		It("fails with the appropriate errors", func() {
    55  			helpers.LoginCF()
    56  			session := helpers.CF("set-space-quota", spaceName, quotaName)
    57  			Eventually(session).Should(Say("FAILED"))
    58  			Eventually(session.Out).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\."))
    59  			Eventually(session).Should(Exit(1))
    60  			//helpers.CheckEnvironmentTargetedCorrectly(true, false, orgName, "set-space-quota", spaceName, quotaName)
    61  		})
    62  	})
    63  
    64  	It("sets the space quota on a space", func() {
    65  		session := helpers.CF("set-space-quota", spaceName, quotaName)
    66  		Eventually(session).Should(Say("Assigning space quota %s to space %s", quotaName, spaceName))
    67  		Eventually(session).Should(Exit(0))
    68  
    69  		session = helpers.CF("space", spaceName)
    70  		Eventually(session).Should(Say(`(?i)space quota:\s+%s`, quotaName))
    71  		Eventually(session).Should(Exit(0))
    72  	})
    73  })