github.com/cloudfoundry/cli@v7.1.0+incompatible/integration/shared/isolated/apps_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 // skipping until refactor 12 var _ = XDescribe("apps command", func() { 13 var ( 14 orgName string 15 spaceName string 16 appName1 string 17 appName2 string 18 ) 19 20 BeforeEach(func() { 21 orgName = helpers.NewOrgName() 22 spaceName = helpers.NewSpaceName() 23 appName1 = helpers.NewAppName() 24 appName2 = helpers.NewAppName() 25 }) 26 27 Describe("help", func() { 28 When("--help flag is set", func() { 29 It("Displays command usage to output", func() { 30 session := helpers.CF("apps", "--help") 31 Eventually(session).Should(Say("NAME:")) 32 Eventually(session).Should(Say("apps - List all apps in the target space")) 33 Eventually(session).Should(Say("USAGE:")) 34 Eventually(session).Should(Say("cf apps")) 35 Eventually(session).Should(Say("ALIAS:")) 36 Eventually(session).Should(Say("a")) 37 Eventually(session).Should(Say("SEE ALSO:")) 38 Eventually(session).Should(Say("events, logs, map-route, push, restart, scale, start, stop")) 39 Eventually(session).Should(Exit(0)) 40 }) 41 }) 42 }) 43 44 When("the environment is not setup correctly", func() { 45 It("fails with the appropriate errors", func() { 46 helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "apps") 47 }) 48 }) 49 50 When("the environment is set up correctly", func() { 51 var userName string 52 53 BeforeEach(func() { 54 helpers.SetupCF(orgName, spaceName) 55 userName, _ = helpers.GetCredentials() 56 }) 57 58 AfterEach(func() { 59 helpers.QuickDeleteOrg(orgName) 60 }) 61 62 Context("with no apps", func() { 63 It("displays empty list", func() { 64 session := helpers.CF("apps") 65 Eventually(session).Should(Say(`Getting apps in org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 66 Eventually(session).Should(Say("No apps found")) 67 Eventually(session).Should(Exit(0)) 68 }) 69 }) 70 71 Context("with existing apps", func() { 72 var domainName string 73 74 BeforeEach(func() { 75 helpers.WithHelloWorldApp(func(appDir string) { 76 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName1)).Should(Exit(0)) 77 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName2)).Should(Exit(0)) 78 }) 79 80 domainName = helpers.DefaultSharedDomain() 81 }) 82 83 It("displays apps in the list", func() { 84 session := helpers.CF("apps") 85 Eventually(session).Should(Say(`Getting apps in org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 86 Eventually(session).Should(Say(`name\s+requested state\s+instances\s+memory\s+disk\s+urls`)) 87 Eventually(session).Should(Say(`%s\s+started\s+1/1\s+8M\s+8M\s+%s\.%s`, appName1, appName1, domainName)) 88 Eventually(session).Should(Say(`%s\s+started\s+1/1\s+8M\s+8M\s+%s\.%s`, appName2, appName2, domainName)) 89 90 Eventually(session).Should(Exit(0)) 91 }) 92 93 When("one app is stopped", func() { 94 BeforeEach(func() { 95 Eventually(helpers.CF("stop", appName1)).Should(Exit(0)) 96 }) 97 98 It("displays app as stopped", func() { 99 session := helpers.CF("apps") 100 Eventually(session).Should(Say(`Getting apps in org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 101 Eventually(session).Should(Say(`name\s+requested state\s+instances\s+memory\s+disk\s+urls`)) 102 Eventually(session).Should(Say(`%s\s+stopped\s+1/1\s+8M\s+8M\s+%s\.%s`, appName1, appName1, domainName)) 103 Eventually(session).Should(Say(`%s\s+started\s+1/1\s+8M\s+8M\s+%s\.%s`, appName2, appName2, domainName)) 104 105 Eventually(session).Should(Exit(0)) 106 }) 107 }) 108 }) 109 }) 110 })