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