github.com/willmadison/cli@v6.40.1-0.20181018160101-29d5937903ff+incompatible/integration/v7/isolated/scale_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"code.cloudfoundry.org/cli/integration/helpers"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  	. "github.com/onsi/gomega/gexec"
    12  )
    13  
    14  var _ = Describe("scale command", func() {
    15  	var (
    16  		orgName   string
    17  		spaceName string
    18  		appName   string
    19  		userName  string
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		orgName = helpers.NewOrgName()
    24  		spaceName = helpers.NewSpaceName()
    25  		appName = helpers.PrefixedRandomName("app")
    26  		userName, _ = helpers.GetCredentials()
    27  	})
    28  
    29  	Describe("help", func() {
    30  		When("--help flag is set", func() {
    31  			It("displays command usage to output", func() {
    32  				session := helpers.CF("scale", "--help")
    33  
    34  				Eventually(session).Should(Say("NAME:"))
    35  				Eventually(session).Should(Say("scale - Change or view the instance count, disk space limit, and memory limit for an app"))
    36  
    37  				Eventually(session).Should(Say("USAGE:"))
    38  				Eventually(session).Should(Say("cf scale APP_NAME \\[--process PROCESS\\] \\[-i INSTANCES\\] \\[-k DISK\\] \\[-m MEMORY\\]"))
    39  
    40  				Eventually(session).Should(Say("OPTIONS:"))
    41  				Eventually(session).Should(Say("-f\\s+Force restart of app without prompt"))
    42  				Eventually(session).Should(Say("-i\\s+Number of instances"))
    43  				Eventually(session).Should(Say("-k\\s+Disk limit \\(e\\.g\\. 256M, 1024M, 1G\\)"))
    44  				Eventually(session).Should(Say("-m\\s+Memory limit \\(e\\.g\\. 256M, 1024M, 1G\\)"))
    45  				Eventually(session).Should(Say("--process\\s+App process to scale \\(Default: web\\)"))
    46  
    47  				Eventually(session).Should(Say("ENVIRONMENT:"))
    48  				Eventually(session).Should(Say("CF_STARTUP_TIMEOUT=5\\s+Max wait time for app instance startup, in minutes"))
    49  
    50  				Eventually(session).Should(Exit(0))
    51  			})
    52  		})
    53  	})
    54  
    55  	When("the environment is not setup correctly", func() {
    56  		When("no API endpoint is set", func() {
    57  			BeforeEach(func() {
    58  				helpers.UnsetAPI()
    59  			})
    60  
    61  			It("fails with no API endpoint set message", func() {
    62  				session := helpers.CF("scale", appName)
    63  				Eventually(session).Should(Say("FAILED"))
    64  				Eventually(session.Err).Should(Say("No API endpoint set\\. Use 'cf login' or 'cf api' to target an endpoint\\."))
    65  				Eventually(session).Should(Exit(1))
    66  			})
    67  		})
    68  
    69  		When("not logged in", func() {
    70  			BeforeEach(func() {
    71  				helpers.LogoutCF()
    72  			})
    73  
    74  			It("fails with not logged in message", func() {
    75  				session := helpers.CF("scale", appName)
    76  				Eventually(session).Should(Say("FAILED"))
    77  				Eventually(session.Err).Should(Say("Not logged in\\. Use 'cf login' to log in\\."))
    78  				Eventually(session).Should(Exit(1))
    79  			})
    80  		})
    81  
    82  		When("there is no org set", func() {
    83  			BeforeEach(func() {
    84  				helpers.LogoutCF()
    85  				helpers.LoginCF()
    86  			})
    87  
    88  			It("fails with no org targeted error message", func() {
    89  				session := helpers.CF("scale", appName)
    90  				Eventually(session).Should(Say("FAILED"))
    91  				Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\."))
    92  				Eventually(session).Should(Exit(1))
    93  			})
    94  		})
    95  
    96  		When("there is no space set", func() {
    97  			BeforeEach(func() {
    98  				helpers.LogoutCF()
    99  				helpers.LoginCF()
   100  				helpers.TargetOrg(ReadOnlyOrg)
   101  			})
   102  
   103  			It("fails with no space targeted error message", func() {
   104  				session := helpers.CF("scale", appName)
   105  				Eventually(session).Should(Say("FAILED"))
   106  				Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space\\."))
   107  				Eventually(session).Should(Exit(1))
   108  			})
   109  		})
   110  	})
   111  
   112  	When("the environment is set up correctly", func() {
   113  		BeforeEach(func() {
   114  			helpers.SetupCF(orgName, spaceName)
   115  		})
   116  
   117  		AfterEach(func() {
   118  			helpers.QuickDeleteOrg(orgName)
   119  		})
   120  
   121  		When("the app name is not provided", func() {
   122  			It("tells the user that the app name is required, prints help text, and exits 1", func() {
   123  				session := helpers.CF("scale")
   124  
   125  				Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `APP_NAME` was not provided"))
   126  				Eventually(session).Should(Say("NAME:"))
   127  				Eventually(session).Should(Exit(1))
   128  			})
   129  		})
   130  
   131  		When("the app does not exist", func() {
   132  			It("displays app not found and exits 1", func() {
   133  				invalidAppName := "invalid-app-name"
   134  				session := helpers.CF("scale", invalidAppName)
   135  				Eventually(session.Err).Should(Say("App %s not found", invalidAppName))
   136  				Eventually(session).Should(Say("FAILED"))
   137  				Eventually(session).Should(Exit(1))
   138  			})
   139  		})
   140  
   141  		When("the app exists", func() {
   142  			BeforeEach(func() {
   143  				helpers.WithProcfileApp(func(appDir string) {
   144  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName)).Should(Exit(0))
   145  				})
   146  			})
   147  
   148  			When("scale option flags are not provided", func() {
   149  				It("displays the current scale properties for all processes", func() {
   150  					session := helpers.CF("scale", appName)
   151  
   152  					Eventually(session).Should(Say("Showing current scale of app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   153  					Consistently(session).ShouldNot(Say("Scaling"))
   154  					Consistently(session).ShouldNot(Say("This will cause the app to restart"))
   155  					Consistently(session).ShouldNot(Say("Stopping"))
   156  					Consistently(session).ShouldNot(Say("Starting"))
   157  					Consistently(session).ShouldNot(Say("Waiting"))
   158  					Eventually(session).Should(Exit(0))
   159  
   160  					appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   161  					Expect(len(appTable.Processes)).To(Equal(3))
   162  
   163  					processSummary := appTable.Processes[0]
   164  					Expect(processSummary.Type).To(Equal("web"))
   165  					Expect(processSummary.InstanceCount).To(Equal("1/1"))
   166  
   167  					instanceSummary := processSummary.Instances[0]
   168  					Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   169  					Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   170  
   171  					Expect(appTable.Processes[1].Type).To(Equal("console"))
   172  					Expect(appTable.Processes[1].InstanceCount).To(Equal("0/0"))
   173  
   174  					Expect(appTable.Processes[2].Type).To(Equal("rake"))
   175  					Expect(appTable.Processes[2].InstanceCount).To(Equal("0/0"))
   176  				})
   177  			})
   178  
   179  			When("only one scale option flag is provided", func() {
   180  				When("scaling the number of instances", func() {
   181  					It("Scales to the correct number of instances", func() {
   182  						By("Verifying we start with one instance")
   183  						session := helpers.CF("scale", appName)
   184  						Eventually(session).Should(Exit(0))
   185  						appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   186  						Expect(appTable.Processes).To(HaveLen(3))
   187  						processSummary := appTable.Processes[0]
   188  						Expect(processSummary.Type).To(Equal("web"))
   189  						Expect(processSummary.InstanceCount).To(Equal("1/1"))
   190  
   191  						By("then scaling to 3 instances")
   192  						session = helpers.CF("scale", appName, "-i", "3")
   193  						Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   194  						Consistently(session).ShouldNot(Say("This will cause the app to restart"))
   195  						Consistently(session).ShouldNot(Say("Stopping"))
   196  						Consistently(session).ShouldNot(Say("Starting"))
   197  						Eventually(session).Should(Exit(0))
   198  						updatedAppTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   199  						Expect(updatedAppTable.Processes).To(HaveLen(3))
   200  						processSummary = updatedAppTable.Processes[0]
   201  						instanceSummary := processSummary.Instances[0]
   202  						Expect(processSummary.Type).To(Equal("web"))
   203  						Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/3`))
   204  						Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   205  						Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   206  					})
   207  				})
   208  
   209  				When("Scaling the memory", func() {
   210  					It("scales memory to 64M", func() {
   211  						buffer := NewBuffer()
   212  						buffer.Write([]byte("y\n"))
   213  						session := helpers.CFWithStdin(buffer, "scale", appName, "-m", "64M")
   214  						Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   215  						Eventually(session).Should(Say("This will cause the app to restart\\. Are you sure you want to scale %s\\? \\[yN\\]:", appName))
   216  						Eventually(session).Should(Say("Stopping app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   217  						Eventually(session).Should(Say("Starting app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   218  						Eventually(session).Should(Exit(0))
   219  
   220  						updatedAppTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   221  						Expect(updatedAppTable.Processes).To(HaveLen(3))
   222  
   223  						processSummary := updatedAppTable.Processes[0]
   224  						instanceSummary := processSummary.Instances[0]
   225  						Expect(processSummary.Type).To(Equal("web"))
   226  						Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/1`))
   227  						Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 64M`))
   228  						Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   229  					})
   230  
   231  					When("-f flag provided", func() {
   232  						It("scales without prompt", func() {
   233  							session := helpers.CF("scale", appName, "-m", "64M", "-f")
   234  							Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))
   235  							Eventually(session).Should(Exit(0))
   236  
   237  							updatedAppTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   238  							Expect(updatedAppTable.Processes).To(HaveLen(3))
   239  
   240  							processSummary := updatedAppTable.Processes[0]
   241  							instanceSummary := processSummary.Instances[0]
   242  							Expect(processSummary.Type).To(Equal("web"))
   243  							Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/1`))
   244  							Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 64M`))
   245  							Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   246  						})
   247  					})
   248  				})
   249  
   250  				When("Scaling the disk space", func() {
   251  					It("scales disk to 92M", func() {
   252  						buffer := NewBuffer()
   253  						buffer.Write([]byte("y\n"))
   254  						session := helpers.CFWithStdin(buffer, "scale", appName, "-k", "92M")
   255  						Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   256  						Eventually(session).Should(Say("This will cause the app to restart\\. Are you sure you want to scale %s\\? \\[yN\\]:", appName))
   257  						Eventually(session).Should(Say("Stopping app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   258  						Eventually(session).Should(Say("Starting app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   259  						Eventually(session).Should(Exit(0))
   260  
   261  						updatedAppTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   262  						Expect(updatedAppTable.Processes).To(HaveLen(3))
   263  
   264  						processSummary := updatedAppTable.Processes[0]
   265  						instanceSummary := processSummary.Instances[0]
   266  						Expect(processSummary.Type).To(Equal("web"))
   267  						Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/1`))
   268  						Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   269  						Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 92M`))
   270  					})
   271  
   272  					When("-f flag provided", func() {
   273  						It("scales without prompt", func() {
   274  							session := helpers.CF("scale", appName, "-k", "92M", "-f")
   275  							Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s...", appName, orgName, spaceName, userName))
   276  							Eventually(session).Should(Exit(0))
   277  
   278  							updatedAppTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   279  							Expect(updatedAppTable.Processes).To(HaveLen(3))
   280  
   281  							processSummary := updatedAppTable.Processes[0]
   282  							instanceSummary := processSummary.Instances[0]
   283  							Expect(processSummary.Type).To(Equal("web"))
   284  							Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/1`))
   285  							Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   286  							Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 92M`))
   287  						})
   288  					})
   289  				})
   290  
   291  				When("Scaling to 0 instances", func() {
   292  					It("scales to 0 instances", func() {
   293  						session := helpers.CF("scale", appName, "-i", "0")
   294  						Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   295  						Consistently(session).ShouldNot(Say(`This will cause the app to restart|Stopping|Starting`))
   296  						Eventually(session).Should(Exit(0))
   297  						updatedAppTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   298  						Expect(updatedAppTable.Processes).To(BeEmpty())
   299  					})
   300  				})
   301  
   302  				When("the user chooses not to restart the app", func() {
   303  					It("cancels the scale", func() {
   304  						buffer := NewBuffer()
   305  						buffer.Write([]byte("n\n"))
   306  						session := helpers.CFWithStdin(buffer, "scale", appName, "-i", "2", "-k", "90M")
   307  						Eventually(session).Should(Say("This will cause the app to restart"))
   308  						Consistently(session).ShouldNot(Say("Stopping"))
   309  						Consistently(session).ShouldNot(Say("Starting"))
   310  						Eventually(session).Should(Say("Scaling cancelled"))
   311  						Consistently(session).ShouldNot(Say("Waiting for app to start\\.\\.\\."))
   312  						Eventually(session).Should(Exit(0))
   313  
   314  						appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   315  						Expect(appTable.Processes).To(BeEmpty())
   316  					})
   317  				})
   318  			})
   319  
   320  			When("all scale option flags are provided", func() {
   321  				When("the app starts successfully", func() {
   322  					It("scales the app accordingly", func() {
   323  						buffer := NewBuffer()
   324  						buffer.Write([]byte("y\n"))
   325  						session := helpers.CFWithStdin(buffer, "scale", appName, "-i", "2", "-k", "120M", "-m", "60M")
   326  						Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   327  						Eventually(session).Should(Say("This will cause the app to restart\\. Are you sure you want to scale %s\\? \\[yN\\]:", appName))
   328  						Eventually(session).Should(Say("Stopping app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   329  						Eventually(session).Should(Say("Starting app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   330  						Eventually(session).Should(Exit(0))
   331  
   332  						appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   333  						Expect(appTable.Processes).To(HaveLen(3))
   334  
   335  						processSummary := appTable.Processes[0]
   336  						instanceSummary := processSummary.Instances[0]
   337  						Expect(processSummary.Type).To(Equal("web"))
   338  						Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/2`))
   339  						Expect(instanceSummary.State).To(MatchRegexp(`running|starting`))
   340  						Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 60M`))
   341  						Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 120M`))
   342  					})
   343  				})
   344  
   345  				When("the app does not start successfully", func() {
   346  					It("scales the app and displays the app summary", func() {
   347  						buffer := NewBuffer()
   348  						buffer.Write([]byte("y\n"))
   349  						session := helpers.CFWithStdin(buffer, "scale", appName, "-i", "2", "-k", "120M", "-m", "6M")
   350  						Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   351  						Eventually(session).Should(Say("This will cause the app to restart\\. Are you sure you want to scale %s\\? \\[yN\\]:", appName))
   352  						Eventually(session).Should(Say("Stopping app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   353  						Eventually(session).Should(Say("Starting app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   354  						Eventually(session).Should(Exit(0))
   355  
   356  						appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   357  						Expect(appTable.Processes).To(HaveLen(3))
   358  
   359  						processSummary := appTable.Processes[0]
   360  						instanceSummary := processSummary.Instances[0]
   361  						Expect(processSummary.Type).To(Equal("web"))
   362  						Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/2`))
   363  						Expect(instanceSummary.State).To(MatchRegexp(`crashed`))
   364  						Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 6M`))
   365  						Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of 120M`))
   366  					})
   367  				})
   368  			})
   369  
   370  			PWhen("the provided scale options are the same as the existing scale properties", func() {
   371  				var (
   372  					session          *Session
   373  					currentInstances string
   374  					maxMemory        string
   375  					maxDiskSize      string
   376  				)
   377  
   378  				BeforeEach(func() {
   379  					session = helpers.CF("scale", appName)
   380  					Eventually(session).Should(Exit(0))
   381  
   382  					appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   383  					instanceSummary := appTable.Processes[0].Instances[0]
   384  					currentInstances = string(len(appTable.Processes[0].Instances))
   385  					maxMemory = strings.Fields(instanceSummary.Memory)[2]
   386  					maxDiskSize = strings.Fields(instanceSummary.Disk)[2]
   387  				})
   388  
   389  				It("the action should be a no-op", func() {
   390  					session = helpers.CF("scale", appName, "-i", currentInstances, "-m", maxMemory, "-k", maxDiskSize)
   391  					Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   392  					Consistently(session).ShouldNot(Say("This will cause the app to restart"))
   393  					Consistently(session).ShouldNot(Say("Stopping"))
   394  					Consistently(session).ShouldNot(Say("Starting"))
   395  					Consistently(session).ShouldNot(Say("Waiting for app to start"))
   396  					Eventually(session).Should(Exit(0))
   397  
   398  					appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   399  					Expect(appTable.Processes).To(HaveLen(1))
   400  
   401  					newProcessSummary := appTable.Processes[0]
   402  					newInstanceSummary := newProcessSummary.Instances[0]
   403  					Expect(newProcessSummary.Type).To(Equal("web"))
   404  					Expect(newProcessSummary.InstanceCount).To(MatchRegexp(fmt.Sprintf(`\d/%s`, currentInstances)))
   405  					Expect(newInstanceSummary.Memory).To(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[KMG]? of %s`, maxMemory)))
   406  					Expect(newInstanceSummary.Disk).To(MatchRegexp(fmt.Sprintf(`\d+(\.\d+)?[KMG]? of %s`, maxDiskSize)))
   407  				})
   408  			})
   409  
   410  			When("the process flag is provided", func() {
   411  				It("scales the requested process", func() {
   412  					session := helpers.CF("scale", appName, "-i", "2", "--process", "console")
   413  					Eventually(session).Should(Say("Scaling app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
   414  					Eventually(session).Should(Exit(0))
   415  
   416  					appTable := helpers.ParseV3AppProcessTable(session.Out.Contents())
   417  					Expect(appTable.Processes).To(HaveLen(3))
   418  
   419  					processSummary := appTable.Processes[1]
   420  					instanceSummary := processSummary.Instances[0]
   421  					Expect(processSummary.Instances).To(HaveLen(2))
   422  					Expect(processSummary.Type).To(Equal("console"))
   423  					Expect(processSummary.InstanceCount).To(MatchRegexp(`\d/2`))
   424  					Expect(instanceSummary.Memory).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   425  					Expect(instanceSummary.Disk).To(MatchRegexp(`\d+(\.\d+)?[KMG]? of \d+[KMG]`))
   426  				})
   427  			})
   428  		})
   429  	})
   430  
   431  	When("invalid scale option values are provided", func() {
   432  		When("a negative value is passed to a flag argument", func() {
   433  			It("outputs an error message to the user, provides help text, and exits 1", func() {
   434  				session := helpers.CF("scale", "some-app", "-i=-5")
   435  				Eventually(session.Err).Should(Say("Incorrect Usage: invalid argument for flag '-i' \\(expected int > 0\\)"))
   436  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   437  				Eventually(session).Should(Exit(1))
   438  
   439  				session = helpers.CF("scale", "some-app", "-k=-5")
   440  				Eventually(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB"))
   441  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   442  				Eventually(session).Should(Exit(1))
   443  
   444  				session = helpers.CF("scale", "some-app", "-m=-5")
   445  				Eventually(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB"))
   446  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   447  				Eventually(session).Should(Exit(1))
   448  			})
   449  		})
   450  
   451  		When("a non-integer value is passed to a flag argument", func() {
   452  			It("outputs an error message to the user, provides help text, and exits 1", func() {
   453  				session := helpers.CF("scale", "some-app", "-i", "not-an-integer")
   454  				Eventually(session.Err).Should(Say("Incorrect Usage: invalid argument for flag '-i' \\(expected int > 0\\)"))
   455  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   456  				Eventually(session).Should(Exit(1))
   457  
   458  				session = helpers.CF("scale", "some-app", "-k", "not-an-integer")
   459  				Eventually(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB"))
   460  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   461  				Eventually(session).Should(Exit(1))
   462  
   463  				session = helpers.CF("scale", "some-app", "-m", "not-an-integer")
   464  				Eventually(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB"))
   465  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   466  				Eventually(session).Should(Exit(1))
   467  			})
   468  		})
   469  
   470  		When("the unit of measurement is not provided", func() {
   471  			It("outputs an error message to the user, provides help text, and exits 1", func() {
   472  				session := helpers.CF("scale", "some-app", "-k", "9")
   473  				Eventually(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB"))
   474  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   475  				Eventually(session).Should(Exit(1))
   476  
   477  				session = helpers.CF("scale", "some-app", "-m", "7")
   478  				Eventually(session.Err).Should(Say("Byte quantity must be an integer with a unit of measurement like M, MB, G, or GB"))
   479  				Eventually(session).Should(Say("cf scale APP_NAME")) // help
   480  				Eventually(session).Should(Exit(1))
   481  			})
   482  		})
   483  	})
   484  })