github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/actor/v7action/application_summary_test.go (about)

     1  package v7action_test
     2  
     3  import (
     4  	"errors"
     5  
     6  	"code.cloudfoundry.org/cli/actor/v7action"
     7  	. "code.cloudfoundry.org/cli/actor/v7action"
     8  	"code.cloudfoundry.org/cli/actor/v7action/v7actionfakes"
     9  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
    10  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
    11  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
    12  	"code.cloudfoundry.org/cli/types"
    13  	"code.cloudfoundry.org/clock"
    14  
    15  	"code.cloudfoundry.org/cli/actor/actionerror"
    16  	. "github.com/onsi/ginkgo"
    17  	. "github.com/onsi/ginkgo/extensions/table"
    18  	. "github.com/onsi/gomega"
    19  )
    20  
    21  var _ = Describe("Application Summary Actions", func() {
    22  	var (
    23  		actor                     *Actor
    24  		fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient
    25  	)
    26  
    27  	BeforeEach(func() {
    28  		fakeCloudControllerClient = new(v7actionfakes.FakeCloudControllerClient)
    29  		actor = NewActor(fakeCloudControllerClient, nil, nil, nil, clock.NewClock())
    30  	})
    31  
    32  	Describe("ApplicationSummary", func() {
    33  		DescribeTable("GetIsolationSegmentName",
    34  			func(summary ApplicationSummary, isoName string, exists bool) {
    35  				name, ok := summary.GetIsolationSegmentName()
    36  				Expect(ok).To(Equal(exists))
    37  				Expect(name).To(Equal(isoName))
    38  			},
    39  
    40  			Entry("when the there are application instances and the isolationSegmentName is set",
    41  				ApplicationSummary{
    42  					ProcessSummaries: ProcessSummaries{
    43  						ProcessSummary{
    44  							InstanceDetails: []ProcessInstance{
    45  								{IsolationSegment: "some-name"},
    46  							},
    47  						},
    48  					},
    49  				},
    50  				"some-name",
    51  				true,
    52  			),
    53  
    54  			Entry("when the there are application instances and the isolationSegmentName is blank",
    55  				ApplicationSummary{
    56  					ProcessSummaries: ProcessSummaries{
    57  						ProcessSummary{InstanceDetails: []ProcessInstance{{}}},
    58  					},
    59  				},
    60  				"",
    61  				false,
    62  			),
    63  
    64  			Entry("when the there are no application instances", ApplicationSummary{ProcessSummaries: ProcessSummaries{{}}}, "", false),
    65  			Entry("when the there are no processes", ApplicationSummary{}, "", false),
    66  		)
    67  	})
    68  
    69  	Describe("GetAppSummariesForSpace", func() {
    70  		var (
    71  			spaceGUID     string
    72  			labelSelector string
    73  
    74  			summaries  []ApplicationSummary
    75  			warnings   Warnings
    76  			executeErr error
    77  		)
    78  
    79  		BeforeEach(func() {
    80  			spaceGUID = "some-space-guid"
    81  			labelSelector = "some-key=some-value"
    82  		})
    83  
    84  		JustBeforeEach(func() {
    85  			summaries, warnings, executeErr = actor.GetAppSummariesForSpace(spaceGUID, labelSelector)
    86  		})
    87  
    88  		When("getting the application is successful", func() {
    89  			BeforeEach(func() {
    90  				fakeCloudControllerClient.GetApplicationsReturns(
    91  					[]ccv3.Application{
    92  						{
    93  							Name:  "some-app-name",
    94  							GUID:  "some-app-guid",
    95  							State: constant.ApplicationStarted,
    96  						},
    97  					},
    98  					ccv3.Warnings{"get-apps-warning"},
    99  					nil,
   100  				)
   101  
   102  				listedProcesses := []ccv3.Process{
   103  					{
   104  						GUID:       "some-process-guid",
   105  						Type:       "some-type",
   106  						Command:    *types.NewFilteredString("[Redacted Value]"),
   107  						MemoryInMB: types.NullUint64{Value: 32, IsSet: true},
   108  					},
   109  					{
   110  						GUID:       "some-process-web-guid",
   111  						Type:       "web",
   112  						Command:    *types.NewFilteredString("[Redacted Value]"),
   113  						MemoryInMB: types.NullUint64{Value: 64, IsSet: true},
   114  					},
   115  				}
   116  				fakeCloudControllerClient.GetApplicationProcessesReturns(
   117  					listedProcesses,
   118  					ccv3.Warnings{"get-app-processes-warning"},
   119  					nil,
   120  				)
   121  
   122  				explicitlyCalledProcess := listedProcesses[0]
   123  				explicitlyCalledProcess.Command = *types.NewFilteredString("some-start-command")
   124  				fakeCloudControllerClient.GetProcessReturnsOnCall(
   125  					0,
   126  					explicitlyCalledProcess,
   127  					ccv3.Warnings{"get-process-by-type-warning"},
   128  					nil,
   129  				)
   130  
   131  				fakeCloudControllerClient.GetProcessReturnsOnCall(
   132  					1,
   133  					listedProcesses[1],
   134  					ccv3.Warnings{"get-process-by-type-warning"},
   135  					nil,
   136  				)
   137  
   138  				fakeCloudControllerClient.GetProcessInstancesReturns(
   139  					[]ccv3.ProcessInstance{
   140  						{
   141  							State:       constant.ProcessInstanceRunning,
   142  							CPU:         0.01,
   143  							MemoryUsage: 1000000,
   144  							DiskUsage:   2000000,
   145  							MemoryQuota: 3000000,
   146  							DiskQuota:   4000000,
   147  							Index:       0,
   148  						},
   149  					},
   150  					ccv3.Warnings{"get-process-instances-warning"},
   151  					nil,
   152  				)
   153  
   154  				fakeCloudControllerClient.GetApplicationRoutesReturns(
   155  					[]ccv3.Route{
   156  						{GUID: "some-route-guid"},
   157  						{GUID: "some-other-route-guid"},
   158  					},
   159  					ccv3.Warnings{"get-routes-warning"},
   160  					nil,
   161  				)
   162  			})
   163  
   164  			It("returns the summary and warnings with droplet information", func() {
   165  				Expect(executeErr).ToNot(HaveOccurred())
   166  				Expect(summaries).To(Equal([]ApplicationSummary{
   167  					{
   168  						Application: Application{
   169  							Name:  "some-app-name",
   170  							GUID:  "some-app-guid",
   171  							State: constant.ApplicationStarted,
   172  						},
   173  						ProcessSummaries: []ProcessSummary{
   174  							{
   175  								Process: Process{
   176  									GUID:       "some-process-web-guid",
   177  									Type:       "web",
   178  									Command:    *types.NewFilteredString("[Redacted Value]"),
   179  									MemoryInMB: types.NullUint64{Value: 64, IsSet: true},
   180  								},
   181  								InstanceDetails: []ProcessInstance{
   182  									{
   183  										State:       constant.ProcessInstanceRunning,
   184  										CPU:         0.01,
   185  										MemoryUsage: 1000000,
   186  										DiskUsage:   2000000,
   187  										MemoryQuota: 3000000,
   188  										DiskQuota:   4000000,
   189  										Index:       0,
   190  									},
   191  								},
   192  							},
   193  							{
   194  								Process: Process{
   195  									GUID:       "some-process-guid",
   196  									MemoryInMB: types.NullUint64{Value: 32, IsSet: true},
   197  									Type:       "some-type",
   198  									Command:    *types.NewFilteredString("[Redacted Value]"),
   199  								},
   200  								InstanceDetails: []ProcessInstance{
   201  									{
   202  										State:       constant.ProcessInstanceRunning,
   203  										CPU:         0.01,
   204  										MemoryUsage: 1000000,
   205  										DiskUsage:   2000000,
   206  										MemoryQuota: 3000000,
   207  										DiskQuota:   4000000,
   208  										Index:       0,
   209  									},
   210  								},
   211  							},
   212  						},
   213  						Routes: []v7action.Route{
   214  							{GUID: "some-route-guid", Destinations: []RouteDestination{}},
   215  							{GUID: "some-other-route-guid", Destinations: []RouteDestination{}},
   216  						},
   217  					},
   218  				}))
   219  
   220  				Expect(warnings).To(ConsistOf(
   221  					"get-apps-warning",
   222  					"get-app-processes-warning",
   223  					"get-process-instances-warning",
   224  					"get-process-instances-warning",
   225  					"get-routes-warning",
   226  				))
   227  
   228  				Expect(fakeCloudControllerClient.GetApplicationsCallCount()).To(Equal(1))
   229  				Expect(fakeCloudControllerClient.GetApplicationsArgsForCall(0)).To(ConsistOf(
   230  					ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}},
   231  					ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}},
   232  					ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{"some-key=some-value"}},
   233  				))
   234  
   235  				Expect(fakeCloudControllerClient.GetApplicationProcessesCallCount()).To(Equal(1))
   236  				Expect(fakeCloudControllerClient.GetApplicationProcessesArgsForCall(0)).To(Equal("some-app-guid"))
   237  
   238  				Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(2))
   239  				Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("some-process-guid"))
   240  			})
   241  
   242  			When("there is no label selector", func() {
   243  				BeforeEach(func() {
   244  					labelSelector = ""
   245  				})
   246  				It("doesn't pass a label selection filter", func() {
   247  					Expect(fakeCloudControllerClient.GetApplicationsCallCount()).To(Equal(1))
   248  					Expect(fakeCloudControllerClient.GetApplicationsArgsForCall(0)).To(ConsistOf(
   249  						ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}},
   250  						ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}},
   251  					))
   252  				})
   253  			})
   254  		})
   255  
   256  		When("getting the application fails", func() {
   257  			BeforeEach(func() {
   258  				fakeCloudControllerClient.GetApplicationsReturns(
   259  					[]ccv3.Application{
   260  						{
   261  							Name:  "some-app-name",
   262  							GUID:  "some-app-guid",
   263  							State: constant.ApplicationStarted,
   264  						},
   265  					},
   266  					ccv3.Warnings{"get-apps-warning"},
   267  					errors.New("failed to get app"),
   268  				)
   269  			})
   270  
   271  			It("returns the error and warnings", func() {
   272  				Expect(executeErr).To(MatchError("failed to get app"))
   273  				Expect(warnings).To(ConsistOf("get-apps-warning"))
   274  			})
   275  		})
   276  	})
   277  
   278  	Describe("GetDetailedAppSummary", func() {
   279  		var (
   280  			appName              string
   281  			spaceGUID            string
   282  			withObfuscatedValues bool
   283  
   284  			summary    DetailedApplicationSummary
   285  			warnings   Warnings
   286  			executeErr error
   287  		)
   288  
   289  		BeforeEach(func() {
   290  			appName = "some-app-name"
   291  			spaceGUID = "some-space-guid"
   292  			withObfuscatedValues = true
   293  		})
   294  
   295  		JustBeforeEach(func() {
   296  			summary, warnings, executeErr = actor.GetDetailedAppSummary(appName, spaceGUID, withObfuscatedValues)
   297  		})
   298  
   299  		When("getting the application is successful", func() {
   300  			BeforeEach(func() {
   301  				fakeCloudControllerClient.GetApplicationsReturns(
   302  					[]ccv3.Application{
   303  						{
   304  							Name:  "some-app-name",
   305  							GUID:  "some-app-guid",
   306  							State: constant.ApplicationStarted,
   307  						},
   308  					},
   309  					ccv3.Warnings{"get-apps-warning"},
   310  					nil,
   311  				)
   312  			})
   313  
   314  			When("getting the process information is successful", func() {
   315  				BeforeEach(func() {
   316  					listedProcesses := []ccv3.Process{
   317  						{
   318  							GUID:       "some-process-guid",
   319  							Type:       "some-type",
   320  							Command:    *types.NewFilteredString("[Redacted Value]"),
   321  							MemoryInMB: types.NullUint64{Value: 32, IsSet: true},
   322  						},
   323  						{
   324  							GUID:       "some-process-web-guid",
   325  							Type:       "web",
   326  							Command:    *types.NewFilteredString("[Redacted Value]"),
   327  							MemoryInMB: types.NullUint64{Value: 64, IsSet: true},
   328  						},
   329  					}
   330  					fakeCloudControllerClient.GetApplicationProcessesReturns(
   331  						listedProcesses,
   332  						ccv3.Warnings{"get-app-processes-warning"},
   333  						nil,
   334  					)
   335  
   336  					explicitlyCalledProcess := listedProcesses[0]
   337  					explicitlyCalledProcess.Command = *types.NewFilteredString("some-start-command")
   338  					fakeCloudControllerClient.GetProcessReturnsOnCall(
   339  						0,
   340  						explicitlyCalledProcess,
   341  						ccv3.Warnings{"get-process-by-type-warning"},
   342  						nil,
   343  					)
   344  
   345  					fakeCloudControllerClient.GetProcessReturnsOnCall(
   346  						1,
   347  						listedProcesses[1],
   348  						ccv3.Warnings{"get-process-by-type-warning"},
   349  						nil,
   350  					)
   351  
   352  					fakeCloudControllerClient.GetProcessSidecarsReturns(
   353  						[]ccv3.Sidecar{
   354  							{
   355  								GUID:    "sidecar-guid",
   356  								Name:    "sidecar_name",
   357  								Command: *types.NewFilteredString("my-sidecar-command"),
   358  							},
   359  						},
   360  						ccv3.Warnings{"get-process-sidecars-warning"},
   361  						nil,
   362  					)
   363  
   364  					fakeCloudControllerClient.GetProcessInstancesReturns(
   365  						[]ccv3.ProcessInstance{
   366  							{
   367  								State:       constant.ProcessInstanceRunning,
   368  								CPU:         0.01,
   369  								MemoryUsage: 1000000,
   370  								DiskUsage:   2000000,
   371  								MemoryQuota: 3000000,
   372  								DiskQuota:   4000000,
   373  								Index:       0,
   374  							},
   375  						},
   376  						ccv3.Warnings{"get-process-instances-warning"},
   377  						nil,
   378  					)
   379  				})
   380  
   381  				When("getting current droplet succeeds", func() {
   382  					BeforeEach(func() {
   383  						fakeCloudControllerClient.GetApplicationDropletCurrentReturns(
   384  							ccv3.Droplet{
   385  								Stack: "some-stack",
   386  								Buildpacks: []ccv3.DropletBuildpack{
   387  									{
   388  										Name: "some-buildpack",
   389  									},
   390  								},
   391  								Image: "docker/some-image",
   392  							},
   393  							ccv3.Warnings{"get-app-droplet-warning"},
   394  							nil,
   395  						)
   396  					})
   397  
   398  					When("getting application routes succeeds", func() {
   399  						BeforeEach(func() {
   400  							fakeCloudControllerClient.GetApplicationRoutesReturns(
   401  								[]ccv3.Route{
   402  									{GUID: "some-route-guid"},
   403  									{GUID: "some-other-route-guid"},
   404  								},
   405  								ccv3.Warnings{"get-routes-warning"},
   406  								nil,
   407  							)
   408  						})
   409  
   410  						It("returns the summary and warnings with droplet information", func() {
   411  							Expect(executeErr).ToNot(HaveOccurred())
   412  							Expect(summary).To(Equal(DetailedApplicationSummary{
   413  								ApplicationSummary: v7action.ApplicationSummary{
   414  									Application: Application{
   415  										Name:  "some-app-name",
   416  										GUID:  "some-app-guid",
   417  										State: constant.ApplicationStarted,
   418  									},
   419  									ProcessSummaries: []ProcessSummary{
   420  										{
   421  											Process: Process{
   422  												GUID:       "some-process-web-guid",
   423  												Type:       "web",
   424  												Command:    *types.NewFilteredString("[Redacted Value]"),
   425  												MemoryInMB: types.NullUint64{Value: 64, IsSet: true},
   426  											},
   427  											Sidecars: []Sidecar{
   428  												{
   429  													GUID:    "sidecar-guid",
   430  													Name:    "sidecar_name",
   431  													Command: *types.NewFilteredString("my-sidecar-command"),
   432  												},
   433  											},
   434  											InstanceDetails: []ProcessInstance{
   435  												{
   436  													State:       constant.ProcessInstanceRunning,
   437  													CPU:         0.01,
   438  													MemoryUsage: 1000000,
   439  													DiskUsage:   2000000,
   440  													MemoryQuota: 3000000,
   441  													DiskQuota:   4000000,
   442  													Index:       0,
   443  												},
   444  											},
   445  										},
   446  										{
   447  											Process: Process{
   448  												GUID:       "some-process-guid",
   449  												MemoryInMB: types.NullUint64{Value: 32, IsSet: true},
   450  												Type:       "some-type",
   451  												Command:    *types.NewFilteredString("some-start-command"),
   452  											},
   453  											Sidecars: []Sidecar{
   454  												{
   455  													GUID:    "sidecar-guid",
   456  													Name:    "sidecar_name",
   457  													Command: *types.NewFilteredString("my-sidecar-command"),
   458  												},
   459  											},
   460  											InstanceDetails: []ProcessInstance{
   461  												{
   462  													State:       constant.ProcessInstanceRunning,
   463  													CPU:         0.01,
   464  													MemoryUsage: 1000000,
   465  													DiskUsage:   2000000,
   466  													MemoryQuota: 3000000,
   467  													DiskQuota:   4000000,
   468  													Index:       0,
   469  												},
   470  											},
   471  										},
   472  									},
   473  									Routes: []v7action.Route{
   474  										{GUID: "some-route-guid", Destinations: []RouteDestination{}},
   475  										{GUID: "some-other-route-guid", Destinations: []RouteDestination{}},
   476  									},
   477  								},
   478  								CurrentDroplet: Droplet{
   479  									Stack: "some-stack",
   480  									Image: "docker/some-image",
   481  									Buildpacks: []DropletBuildpack{
   482  										{
   483  											Name: "some-buildpack",
   484  										},
   485  									},
   486  								},
   487  							}))
   488  
   489  							Expect(warnings).To(ConsistOf(
   490  								"get-apps-warning",
   491  								"get-app-processes-warning",
   492  								"get-process-by-type-warning",
   493  								"get-process-by-type-warning",
   494  								"get-process-instances-warning",
   495  								"get-process-instances-warning",
   496  								"get-process-sidecars-warning",
   497  								"get-process-sidecars-warning",
   498  								"get-app-droplet-warning",
   499  								"get-routes-warning",
   500  							))
   501  
   502  							Expect(fakeCloudControllerClient.GetApplicationsCallCount()).To(Equal(1))
   503  							Expect(fakeCloudControllerClient.GetApplicationsArgsForCall(0)).To(ConsistOf(
   504  								ccv3.Query{Key: ccv3.NameFilter, Values: []string{"some-app-name"}},
   505  								ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}},
   506  							))
   507  
   508  							Expect(fakeCloudControllerClient.GetApplicationDropletCurrentCallCount()).To(Equal(1))
   509  							Expect(fakeCloudControllerClient.GetApplicationDropletCurrentArgsForCall(0)).To(Equal("some-app-guid"))
   510  
   511  							Expect(fakeCloudControllerClient.GetApplicationProcessesCallCount()).To(Equal(1))
   512  							Expect(fakeCloudControllerClient.GetApplicationProcessesArgsForCall(0)).To(Equal("some-app-guid"))
   513  
   514  							Expect(fakeCloudControllerClient.GetProcessCallCount()).To(Equal(2))
   515  							processGUID := fakeCloudControllerClient.GetProcessArgsForCall(0)
   516  							Expect(processGUID).To(Equal("some-process-guid"))
   517  
   518  							Expect(fakeCloudControllerClient.GetProcessInstancesCallCount()).To(Equal(2))
   519  							Expect(fakeCloudControllerClient.GetProcessInstancesArgsForCall(0)).To(Equal("some-process-guid"))
   520  						})
   521  					})
   522  
   523  					When("getting application routes fails", func() {
   524  						BeforeEach(func() {
   525  							fakeCloudControllerClient.GetApplicationRoutesReturns(nil, ccv3.Warnings{"get-routes-warnings"}, errors.New("some-error"))
   526  						})
   527  
   528  						It("returns the warnings and error", func() {
   529  							Expect(executeErr).To(MatchError("some-error"))
   530  							Expect(warnings).To(ConsistOf(
   531  								"get-apps-warning",
   532  								"get-app-processes-warning",
   533  								"get-process-by-type-warning",
   534  								"get-process-by-type-warning",
   535  								"get-process-instances-warning",
   536  								"get-process-instances-warning",
   537  								"get-process-sidecars-warning",
   538  								"get-process-sidecars-warning",
   539  								"get-routes-warnings",
   540  							))
   541  						})
   542  					})
   543  				})
   544  
   545  				When("app does not have current droplet", func() {
   546  					BeforeEach(func() {
   547  						fakeCloudControllerClient.GetApplicationDropletCurrentReturns(
   548  							ccv3.Droplet{},
   549  							ccv3.Warnings{"get-app-droplet-warning"},
   550  							ccerror.DropletNotFoundError{},
   551  						)
   552  					})
   553  
   554  					It("returns the summary and warnings without droplet information", func() {
   555  						Expect(executeErr).ToNot(HaveOccurred())
   556  						Expect(summary).To(Equal(DetailedApplicationSummary{
   557  							ApplicationSummary: v7action.ApplicationSummary{
   558  								Application: Application{
   559  									Name:  "some-app-name",
   560  									GUID:  "some-app-guid",
   561  									State: constant.ApplicationStarted,
   562  								},
   563  								ProcessSummaries: []ProcessSummary{
   564  									{
   565  										Process: Process{
   566  											GUID:       "some-process-web-guid",
   567  											Type:       "web",
   568  											Command:    *types.NewFilteredString("[Redacted Value]"),
   569  											MemoryInMB: types.NullUint64{Value: 64, IsSet: true},
   570  										},
   571  										Sidecars: []Sidecar{
   572  											{
   573  												GUID:    "sidecar-guid",
   574  												Name:    "sidecar_name",
   575  												Command: *types.NewFilteredString("my-sidecar-command"),
   576  											},
   577  										},
   578  										InstanceDetails: []ProcessInstance{
   579  											{
   580  												State:       constant.ProcessInstanceRunning,
   581  												CPU:         0.01,
   582  												MemoryUsage: 1000000,
   583  												DiskUsage:   2000000,
   584  												MemoryQuota: 3000000,
   585  												DiskQuota:   4000000,
   586  												Index:       0,
   587  											},
   588  										},
   589  									},
   590  									{
   591  										Process: Process{
   592  											GUID:       "some-process-guid",
   593  											MemoryInMB: types.NullUint64{Value: 32, IsSet: true},
   594  											Type:       "some-type",
   595  											Command:    *types.NewFilteredString("some-start-command"),
   596  										},
   597  										Sidecars: []Sidecar{
   598  											{
   599  												GUID:    "sidecar-guid",
   600  												Name:    "sidecar_name",
   601  												Command: *types.NewFilteredString("my-sidecar-command"),
   602  											},
   603  										},
   604  										InstanceDetails: []ProcessInstance{
   605  											{
   606  												State:       constant.ProcessInstanceRunning,
   607  												CPU:         0.01,
   608  												MemoryUsage: 1000000,
   609  												DiskUsage:   2000000,
   610  												MemoryQuota: 3000000,
   611  												DiskQuota:   4000000,
   612  												Index:       0,
   613  											},
   614  										},
   615  									},
   616  								},
   617  							},
   618  						}))
   619  
   620  						Expect(warnings).To(ConsistOf(
   621  							"get-apps-warning",
   622  							"get-app-processes-warning",
   623  							"get-process-by-type-warning",
   624  							"get-process-by-type-warning",
   625  							"get-process-instances-warning",
   626  							"get-process-instances-warning",
   627  							"get-process-sidecars-warning",
   628  							"get-process-sidecars-warning",
   629  							"get-app-droplet-warning",
   630  						))
   631  					})
   632  				})
   633  
   634  				When("getting the current droplet returns an error", func() {
   635  					var expectedErr error
   636  
   637  					BeforeEach(func() {
   638  						expectedErr = errors.New("some error")
   639  						fakeCloudControllerClient.GetApplicationDropletCurrentReturns(
   640  							ccv3.Droplet{},
   641  							ccv3.Warnings{"get-droplet-warning"},
   642  							expectedErr,
   643  						)
   644  					})
   645  
   646  					It("returns the error", func() {
   647  						Expect(executeErr).To(Equal(expectedErr))
   648  						Expect(warnings).To(ConsistOf(
   649  							"get-apps-warning",
   650  							"get-app-processes-warning",
   651  							"get-process-by-type-warning",
   652  							"get-process-by-type-warning",
   653  							"get-process-instances-warning",
   654  							"get-process-instances-warning",
   655  							"get-process-sidecars-warning",
   656  							"get-process-sidecars-warning",
   657  							"get-droplet-warning",
   658  						))
   659  					})
   660  				})
   661  			})
   662  
   663  			When("getting the app processes returns an error", func() {
   664  				var expectedErr error
   665  
   666  				BeforeEach(func() {
   667  					fakeCloudControllerClient.GetApplicationProcessesReturns(
   668  						[]ccv3.Process{
   669  							{
   670  								GUID: "some-process-guid",
   671  								Type: "some-type",
   672  							},
   673  						},
   674  						ccv3.Warnings{"get-app-processes-warning"},
   675  						nil,
   676  					)
   677  
   678  					fakeCloudControllerClient.GetProcessReturns(
   679  						ccv3.Process{},
   680  						ccv3.Warnings{"get-process-warning"},
   681  						nil,
   682  					)
   683  
   684  					expectedErr = errors.New("some error")
   685  					fakeCloudControllerClient.GetProcessInstancesReturns(
   686  						[]ccv3.ProcessInstance{},
   687  						ccv3.Warnings{"get-process-instances-warning"},
   688  						expectedErr,
   689  					)
   690  				})
   691  
   692  				It("returns the error and warnings", func() {
   693  					Expect(executeErr).To(Equal(expectedErr))
   694  					Expect(warnings).To(ConsistOf("get-apps-warning", "get-app-processes-warning", "get-process-warning", "get-process-instances-warning"))
   695  				})
   696  			})
   697  		})
   698  
   699  		When("no applications are returned", func() {
   700  			BeforeEach(func() {
   701  				fakeCloudControllerClient.GetApplicationsReturns(
   702  					[]ccv3.Application{},
   703  					ccv3.Warnings{"get-apps-warning"},
   704  					nil,
   705  				)
   706  			})
   707  
   708  			It("returns an error and warnings", func() {
   709  				Expect(executeErr).To(MatchError(actionerror.ApplicationNotFoundError{Name: appName}))
   710  				Expect(warnings).To(ConsistOf("get-apps-warning"))
   711  			})
   712  		})
   713  
   714  		When("getting the application fails", func() {
   715  			BeforeEach(func() {
   716  				fakeCloudControllerClient.GetApplicationsReturns(
   717  					[]ccv3.Application{
   718  						{
   719  							Name:  "some-app-name",
   720  							GUID:  "some-app-guid",
   721  							State: constant.ApplicationStarted,
   722  						},
   723  					},
   724  					ccv3.Warnings{"get-apps-warning"},
   725  					errors.New("failed to get app"),
   726  				)
   727  			})
   728  
   729  			It("returns the error and warnings", func() {
   730  				Expect(executeErr).To(MatchError("failed to get app"))
   731  				Expect(warnings).To(ConsistOf("get-apps-warning"))
   732  			})
   733  		})
   734  	})
   735  })