github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/isolated/restart_app_instance_command_test.go (about) 1 package isolated 2 3 import ( 4 "code.cloudfoundry.org/cli/integration/helpers" 5 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 _ = XDescribe("restart command", func() { 13 Describe("help", func() { 14 Context("when --help flag is set", func() { 15 It("Displays command usage to output", func() { 16 session := helpers.CF("restart-app-instance", "--help") 17 18 Eventually(session).Should(Say("NAME:")) 19 Eventually(session).Should(Say("restart-app-instance - Terminate, then restart an app instance")) 20 Eventually(session).Should(Say("USAGE:")) 21 Eventually(session).Should(Say("cf restart-app-instance APP_NAME INDEX")) 22 Eventually(session).Should(Say("SEE ALSO:")) 23 Eventually(session).Should(Say("restart")) 24 Eventually(session).Should(Exit(0)) 25 }) 26 }) 27 }) 28 29 Context("when the environment is not setup correctly", func() { 30 It("fails with the appropriate errors", func() { 31 helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "restart-app-instance", "app-name", "2") 32 }) 33 }) 34 35 Context("when the environment is set up correctly", func() { 36 var ( 37 orgName string 38 spaceName string 39 userName string 40 appName string 41 ) 42 43 BeforeEach(func() { 44 orgName = helpers.NewOrgName() 45 spaceName = helpers.NewSpaceName() 46 appName = helpers.NewAppName() 47 48 setupCF(orgName, spaceName) 49 userName, _ = helpers.GetCredentials() 50 }) 51 52 AfterEach(func() { 53 helpers.QuickDeleteOrg(orgName) 54 }) 55 56 Context("when the app does not exist", func() { 57 It("tells the user that the start is not found and exits 1", func() { 58 session := helpers.CF("restart", appName, "0") 59 60 Eventually(session).Should(Say("FAILED")) 61 Eventually(session.Err).Should(Say("App %s not found", appName)) 62 Eventually(session).Should(Exit(1)) 63 }) 64 }) 65 66 Context("when the app does exist", func() { 67 BeforeEach(func() { 68 helpers.WithHelloWorldApp(func(appDir string) { 69 Eventually(helpers.CF("push", appName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0)) 70 }) 71 72 It("restarts app instance", func() { 73 session := helpers.CF("restart", appName) 74 Eventually(session).Should(Say("Restarting instance %d of the app %s in org %s / space %s as %s\\.\\.\\.", 10, appName, orgName, spaceName, userName)) 75 Eventually(session).Should(Say("OK")) 76 Eventually(session).Should(Exit(0)) 77 }) 78 }) 79 }) 80 }) 81 })