github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/v6/experimental/v3_droplets_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-droplets 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.NewAppName() 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-droplets", "--help") 28 29 Eventually(session).Should(Say("NAME:")) 30 Eventually(session).Should(Say("v3-droplets - List droplets of an app")) 31 Eventually(session).Should(Say("USAGE:")) 32 Eventually(session).Should(Say("cf v3-droplets 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-droplets") 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-droplets", 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-droplets", appName) 58 }) 59 }) 60 61 When("the environment is set up correctly", func() { 62 var userName string 63 64 BeforeEach(func() { 65 helpers.SetupCF(orgName, spaceName) 66 userName, _ = helpers.GetCredentials() 67 }) 68 69 AfterEach(func() { 70 helpers.QuickDeleteOrg(orgName) 71 }) 72 73 When("the app does not exist", func() { 74 It("displays app not found and exits 1", func() { 75 session := helpers.CF("v3-droplets", appName) 76 77 Eventually(session).Should(Say(`Listing droplets of app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) 78 Eventually(session.Err).Should(Say("App '%s' not found", appName)) 79 Eventually(session).Should(Say("FAILED")) 80 81 Eventually(session).Should(Exit(1)) 82 }) 83 }) 84 85 When("the app exists", func() { 86 Context("with no droplets", func() { 87 BeforeEach(func() { 88 Eventually(helpers.CF("v3-create-app", appName)).Should(Exit(0)) 89 }) 90 91 It("displays empty list", func() { 92 session := helpers.CF("v3-droplets", appName) 93 Eventually(session).Should(Say(`Listing droplets of app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) 94 Eventually(session).Should(Say("No droplets found")) 95 Eventually(session).Should(Exit(0)) 96 }) 97 }) 98 99 Context("with existing droplets", func() { 100 BeforeEach(func() { 101 helpers.WithHelloWorldApp(func(dir string) { 102 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, "v3-push", appName)).Should(Exit(0)) 103 }) 104 }) 105 106 It("displays droplets in the list", func() { 107 session := helpers.CF("v3-droplets", appName) 108 Eventually(session).Should(Say(`Listing droplets of app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName)) 109 Eventually(session).Should(Say(`guid\s+state\s+created`)) 110 Eventually(session).Should(Say(`\s+.*\s+staged\s+%s`, helpers.UserFriendlyDateRegex)) 111 112 Eventually(session).Should(Exit(0)) 113 }) 114 }) 115 }) 116 }) 117 })