github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/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 Context("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 Context("when the environment is not setup correctly", func() { 45 Context("when no API endpoint is set", func() { 46 BeforeEach(func() { 47 helpers.UnsetAPI() 48 }) 49 50 It("fails with no API endpoint set message", func() { 51 session := helpers.CF("apps") 52 Eventually(session).Should(Say("FAILED")) 53 Eventually(session.Err).Should(Say("No API endpoint set\\. Use 'cf login' or 'cf api' to target an endpoint\\.")) 54 Eventually(session).Should(Exit(1)) 55 }) 56 }) 57 58 Context("when not logged in", func() { 59 BeforeEach(func() { 60 helpers.LogoutCF() 61 }) 62 63 It("fails with not logged in message", func() { 64 session := helpers.CF("apps") 65 Eventually(session).Should(Say("FAILED")) 66 Eventually(session.Err).Should(Say("Not logged in\\. Use 'cf login' to log in\\.")) 67 Eventually(session).Should(Exit(1)) 68 }) 69 }) 70 71 Context("when there is no org set", func() { 72 BeforeEach(func() { 73 helpers.LogoutCF() 74 helpers.LoginCF() 75 }) 76 77 It("fails with no org targeted error message", func() { 78 session := helpers.CF("apps") 79 Eventually(session.Out).Should(Say("FAILED")) 80 Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\.")) 81 Eventually(session).Should(Exit(1)) 82 }) 83 }) 84 85 Context("when there is no space set", func() { 86 BeforeEach(func() { 87 helpers.LogoutCF() 88 helpers.LoginCF() 89 helpers.TargetOrg(ReadOnlyOrg) 90 }) 91 92 It("fails with no space targeted error message", func() { 93 session := helpers.CF("apps") 94 Eventually(session.Out).Should(Say("FAILED")) 95 Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space\\.")) 96 Eventually(session).Should(Exit(1)) 97 }) 98 }) 99 }) 100 101 Context("when the environment is set up correctly", func() { 102 var userName string 103 104 BeforeEach(func() { 105 setupCF(orgName, spaceName) 106 userName, _ = helpers.GetCredentials() 107 }) 108 109 AfterEach(func() { 110 helpers.QuickDeleteOrg(orgName) 111 }) 112 113 Context("with no apps", func() { 114 It("displays empty list", func() { 115 session := helpers.CF("apps") 116 Eventually(session).Should(Say("Getting apps in org %s / space %s as %s\\.\\.\\.", orgName, spaceName, userName)) 117 Eventually(session).Should(Say("No apps found")) 118 Eventually(session).Should(Exit(0)) 119 }) 120 }) 121 122 Context("with existing apps", func() { 123 var domainName string 124 125 BeforeEach(func() { 126 helpers.WithHelloWorldApp(func(appDir string) { 127 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v2-push", appName1)).Should(Exit(0)) 128 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v2-push", appName2)).Should(Exit(0)) 129 }) 130 131 domainName = defaultSharedDomain() 132 }) 133 134 It("displays apps in the list", func() { 135 session := helpers.CF("apps") 136 Eventually(session).Should(Say("Getting apps in org %s / space %s as %s\\.\\.\\.", orgName, spaceName, userName)) 137 Eventually(session).Should(Say("name\\s+requested state\\s+instances\\s+memory\\s+disk\\s+urls")) 138 Eventually(session).Should(Say("%s\\s+started\\s+1/1\\s+8M\\s+8M\\s+%s\\.%s", appName1, appName1, domainName)) 139 Eventually(session).Should(Say("%s\\s+started\\s+1/1\\s+8M\\s+8M\\s+%s\\.%s", appName2, appName2, domainName)) 140 141 Eventually(session).Should(Exit(0)) 142 }) 143 144 Context("when one app is stopped", func() { 145 BeforeEach(func() { 146 Eventually(helpers.CF("stop", appName1)).Should(Exit(0)) 147 }) 148 149 It("displays app as stopped", func() { 150 session := helpers.CF("apps") 151 Eventually(session).Should(Say("Getting apps in org %s / space %s as %s\\.\\.\\.", orgName, spaceName, userName)) 152 Eventually(session).Should(Say("name\\s+requested state\\s+instances\\s+memory\\s+disk\\s+urls")) 153 Eventually(session).Should(Say("%s\\s+stopped\\s+1/1\\s+8M\\s+8M\\s+%s\\.%s", appName1, appName1, domainName)) 154 Eventually(session).Should(Say("%s\\s+started\\s+1/1\\s+8M\\s+8M\\s+%s\\.%s", appName2, appName2, domainName)) 155 156 Eventually(session).Should(Exit(0)) 157 }) 158 }) 159 }) 160 }) 161 })