github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/v6/experimental/v3_stop_application_command_test.go (about) 1 package experimental 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("v3-stop-application command", func() { 12 var ( 13 orgName string 14 spaceName string 15 appName string 16 ) 17 18 BeforeEach(func() { 19 orgName = helpers.NewOrgName() 20 spaceName = helpers.NewSpaceName() 21 appName = helpers.PrefixedRandomName("app") 22 }) 23 24 Describe("help", func() { 25 When("--help flag is set", func() { 26 It("Displays command usage to output", func() { 27 session := helpers.CF("v3-stop", "--help") 28 29 Eventually(session).Should(Say("NAME:")) 30 Eventually(session).Should(Say("v3-stop - Stop an app")) 31 Eventually(session).Should(Say("USAGE:")) 32 Eventually(session).Should(Say("cf v3-stop APP_NAME")) 33 34 Eventually(session).Should(Exit(0)) 35 }) 36 }) 37 }) 38 39 When("the app name is not provided", func() { 40 It("tells the user that the app name is required, prints help text, and exits 1", func() { 41 session := helpers.CF("v3-stop") 42 43 Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `APP_NAME` was not provided")) 44 Eventually(session).Should(Say("NAME:")) 45 Eventually(session).Should(Exit(1)) 46 }) 47 }) 48 49 It("displays the experimental warning", func() { 50 session := helpers.CF("v3-stop", appName) 51 Eventually(session.Err).Should(Say("This command is in EXPERIMENTAL stage and may change without notice")) 52 Eventually(session).Should(Exit()) 53 }) 54 55 When("the environment is not setup correctly", func() { 56 It("fails with the appropriate errors", func() { 57 helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "v3-stop", appName) 58 }) 59 }) 60 61 When("the environment is set up correctly", func() { 62 BeforeEach(func() { 63 helpers.SetupCF(orgName, spaceName) 64 }) 65 66 AfterEach(func() { 67 helpers.QuickDeleteOrg(orgName) 68 }) 69 70 When("the app exists", func() { 71 BeforeEach(func() { 72 helpers.WithHelloWorldApp(func(appDir string) { 73 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName)).Should(Exit(0)) 74 }) 75 }) 76 77 It("stops the app", func() { 78 userName, _ := helpers.GetCredentials() 79 80 session := helpers.CF("v3-stop", appName) 81 Eventually(session).Should(Say(`Stopping app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) 82 Eventually(session).Should(Say("OK")) 83 84 Eventually(session).Should(Exit(0)) 85 }) 86 87 When("the app is already stopped", func() { 88 BeforeEach(func() { 89 Eventually(helpers.CF("v3-stop", appName)).Should(Exit(0)) 90 }) 91 92 It("displays that the app is already stopped", func() { 93 session := helpers.CF("v3-stop", appName) 94 95 Eventually(session.Err).Should(Say("App %s is already stopped", appName)) 96 Eventually(session).Should(Say("OK")) 97 98 Eventually(session).Should(Exit(0)) 99 }) 100 }) 101 102 When("the app does not exist", func() { 103 It("displays app not found and exits 1", func() { 104 invalidAppName := "invalid-app-name" 105 session := helpers.CF("v3-stop", invalidAppName) 106 107 Eventually(session.Err).Should(Say("App '%s' not found", invalidAppName)) 108 Eventually(session).Should(Say("FAILED")) 109 110 Eventually(session).Should(Exit(1)) 111 }) 112 }) 113 }) 114 }) 115 })