github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v6/global/feature_flags_command_test.go (about) 1 package global 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("feature-flags command", func() { 12 Describe("help", func() { 13 When("--help flag is set", func() { 14 It("displays command usage to output", func() { 15 session := helpers.CF("feature-flags", "--help") 16 Eventually(session).Should(Say("NAME:")) 17 Eventually(session).Should(Say(`\s+feature-flags - Retrieve list of feature flags with status`)) 18 Eventually(session).Should(Say("")) 19 Eventually(session).Should(Say("USAGE:")) 20 Eventually(session).Should(Say(`\s+cf feature-flags`)) 21 Eventually(session).Should(Say("")) 22 Eventually(session).Should(Say("SEE ALSO:")) 23 Eventually(session).Should(Say(`\s+disable-feature-flag, enable-feature-flag`)) 24 Eventually(session).Should(Exit(0)) 25 }) 26 }) 27 }) 28 29 When("the API endpoint is not set", func() { 30 BeforeEach(func() { 31 helpers.UnsetAPI() 32 }) 33 34 It("displays an error message and exits 1", func() { 35 session := helpers.CF("feature-flags") 36 Eventually(session).Should(Say("FAILED")) 37 Eventually(session.Err).Should(Say(`No API endpoint set\. Use 'cf login' or 'cf api' to target an endpoint\.`)) 38 Eventually(session).Should(Exit(1)) 39 }) 40 }) 41 42 When("the user is not logged in", func() { 43 BeforeEach(func() { 44 helpers.LogoutCF() 45 }) 46 47 It("displays an error and exits 1", func() { 48 session := helpers.CF("feature-flags") 49 Eventually(session).Should(Say("FAILED")) 50 Eventually(session.Err).Should(Say(`Not logged in\. Use 'cf login' or 'cf login --sso' to log in\.`)) 51 Eventually(session).Should(Exit(1)) 52 }) 53 }) 54 55 When("the API endpoint is set and the user is logged in", func() { 56 BeforeEach(func() { 57 helpers.LoginCF() 58 }) 59 60 It("displays a list of feature flags with current state and exits 0", func() { 61 username, _ := helpers.GetCredentials() 62 session := helpers.CF("feature-flags") 63 Eventually(session).Should(Say(`Retrieving status of all flagged features as %s\.\.\.`, username)) 64 Eventually(session).Should(Say("")) 65 Eventually(session).Should(Say(`features\s+state`)) 66 Eventually(session).Should(Say(`[a-z_]+\s+(enabled|disabled)`)) 67 Eventually(session).Should(Exit(0)) 68 }) 69 }) 70 })