github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/isolated/feature_flags_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("feature-flags command", func() {
    13  	When("--help flag is set", func() {
    14  		It("appears in cf help -a", func() {
    15  			session := helpers.CF("help", "-a")
    16  			Eventually(session).Should(Exit(0))
    17  			Expect(session).To(HaveCommandInCategoryWithDescription("feature-flags", "FEATURE FLAGS", "Retrieve list of feature flags with status"))
    18  		})
    19  
    20  		It("Displays command usage to output", func() {
    21  			session := helpers.CF("feature-flags", "--help")
    22  
    23  			Eventually(session).Should(Say("NAME:"))
    24  			Eventually(session).Should(Say(`feature-flags - Retrieve list of feature flags with status`))
    25  			Eventually(session).Should(Say("USAGE:"))
    26  			Eventually(session).Should(Say(`cf feature-flags`))
    27  			Eventually(session).Should(Say("SEE ALSO:"))
    28  			Eventually(session).Should(Say(`disable-feature-flag, enable-feature-flag, feature-flag`))
    29  
    30  			Eventually(session).Should(Exit(0))
    31  		})
    32  	})
    33  
    34  	When("environment is not set up correctly", func() {
    35  		It("displays an error and exits 1", func() {
    36  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "feature-flags")
    37  		})
    38  	})
    39  
    40  	When("environment is set up correctly", func() {
    41  		BeforeEach(func() {
    42  			helpers.LoginCF()
    43  		})
    44  
    45  		It("displays feature flag settings", func() {
    46  			session := helpers.CF("feature-flags")
    47  			username, _ := helpers.GetCredentials()
    48  			Eventually(session).Should(Say(`Getting feature flags as %s\.\.\.`, username))
    49  			Eventually(session).Should(Say(`name\s+state`))
    50  			Eventually(session).Should(Say(`app_scaling\s+(dis|en)abled`))
    51  			Eventually(session).Should(Say(`service_instance_creation\s+(dis|en)abled`))
    52  			Eventually(session).Should(Say(`user_org_creation\s+(dis|en)abled`))
    53  			Eventually(session).Should(Exit(0))
    54  		})
    55  	})
    56  })