github.com/orange-cloudfoundry/cli@v7.1.0+incompatible/command/v7/map_route_command_test.go (about) 1 package v7_test 2 3 import ( 4 "errors" 5 6 "code.cloudfoundry.org/cli/actor/actionerror" 7 "code.cloudfoundry.org/cli/actor/v7action" 8 "code.cloudfoundry.org/cli/command/commandfakes" 9 "code.cloudfoundry.org/cli/command/flag" 10 . "code.cloudfoundry.org/cli/command/v7" 11 "code.cloudfoundry.org/cli/command/v7/v7fakes" 12 "code.cloudfoundry.org/cli/resources" 13 "code.cloudfoundry.org/cli/util/configv3" 14 "code.cloudfoundry.org/cli/util/ui" 15 16 . "github.com/onsi/ginkgo" 17 . "github.com/onsi/gomega" 18 . "github.com/onsi/gomega/gbytes" 19 ) 20 21 var _ = Describe("map-route Command", func() { 22 var ( 23 cmd MapRouteCommand 24 testUI *ui.UI 25 fakeConfig *commandfakes.FakeConfig 26 fakeSharedActor *commandfakes.FakeSharedActor 27 fakeActor *v7fakes.FakeActor 28 input *Buffer 29 binaryName string 30 executeErr error 31 domain string 32 appName string 33 hostname string 34 path string 35 orgGUID string 36 spaceGUID string 37 ) 38 39 BeforeEach(func() { 40 input = NewBuffer() 41 testUI = ui.NewTestUI(input, NewBuffer(), NewBuffer()) 42 fakeConfig = new(commandfakes.FakeConfig) 43 fakeSharedActor = new(commandfakes.FakeSharedActor) 44 fakeActor = new(v7fakes.FakeActor) 45 46 binaryName = "faceman" 47 fakeConfig.BinaryNameReturns(binaryName) 48 appName = "my-app" 49 domain = "some-domain.com" 50 hostname = "host" 51 path = `path` 52 orgGUID = "some-org-guid" 53 spaceGUID = "some-space-guid" 54 55 cmd = MapRouteCommand{ 56 RequiredArgs: flag.AppDomain{App: appName, Domain: domain}, 57 Hostname: hostname, 58 Path: flag.V7RoutePath{Path: path}, 59 BaseCommand: BaseCommand{ 60 UI: testUI, 61 Config: fakeConfig, 62 SharedActor: fakeSharedActor, 63 Actor: fakeActor, 64 }, 65 } 66 67 fakeConfig.TargetedOrganizationReturns(configv3.Organization{ 68 Name: "some-org", 69 GUID: orgGUID, 70 }) 71 72 fakeConfig.TargetedSpaceReturns(configv3.Space{ 73 Name: "some-space", 74 GUID: spaceGUID, 75 }) 76 77 fakeConfig.CurrentUserReturns(configv3.User{Name: "steve"}, nil) 78 }) 79 80 JustBeforeEach(func() { 81 executeErr = cmd.Execute(nil) 82 }) 83 84 When("checking target fails", func() { 85 BeforeEach(func() { 86 fakeSharedActor.CheckTargetReturns(actionerror.NoOrganizationTargetedError{BinaryName: binaryName}) 87 }) 88 89 It("returns an error", func() { 90 Expect(executeErr).To(MatchError(actionerror.NoOrganizationTargetedError{BinaryName: binaryName})) 91 92 Expect(fakeSharedActor.CheckTargetCallCount()).To(Equal(1)) 93 checkTargetedOrg, checkTargetedSpace := fakeSharedActor.CheckTargetArgsForCall(0) 94 Expect(checkTargetedOrg).To(BeTrue()) 95 Expect(checkTargetedSpace).To(BeTrue()) 96 }) 97 }) 98 99 When("the user is not logged in", func() { 100 var expectedErr error 101 102 BeforeEach(func() { 103 expectedErr = errors.New("some current user error") 104 fakeConfig.CurrentUserReturns(configv3.User{}, expectedErr) 105 }) 106 107 It("return an error", func() { 108 Expect(executeErr).To(Equal(expectedErr)) 109 }) 110 }) 111 112 When("the user is logged in and targeted", func() { 113 When("getting the domain errors", func() { 114 BeforeEach(func() { 115 fakeActor.GetDomainByNameReturns(resources.Domain{}, v7action.Warnings{"get-domain-warnings"}, errors.New("get-domain-error")) 116 }) 117 118 It("returns the error and displays warnings", func() { 119 Expect(testUI.Err).To(Say("get-domain-warnings")) 120 Expect(executeErr).To(MatchError(errors.New("get-domain-error"))) 121 122 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 123 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 124 125 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(0)) 126 127 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) 128 129 Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) 130 131 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 132 }) 133 }) 134 135 When("getting the domain succeeds", func() { 136 BeforeEach(func() { 137 fakeActor.GetDomainByNameReturns( 138 resources.Domain{Name: "some-domain.com", GUID: "domain-guid"}, 139 v7action.Warnings{"get-domain-warnings"}, 140 nil, 141 ) 142 }) 143 144 When("getting the app errors", func() { 145 BeforeEach(func() { 146 fakeActor.GetApplicationByNameAndSpaceReturns( 147 resources.Application{}, 148 v7action.Warnings{"get-app-warnings"}, 149 errors.New("get-app-error"), 150 ) 151 }) 152 153 It("returns the error and displays warnings", func() { 154 Expect(testUI.Err).To(Say("get-domain-warnings")) 155 Expect(testUI.Err).To(Say("get-app-warnings")) 156 Expect(executeErr).To(MatchError(errors.New("get-app-error"))) 157 158 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 159 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 160 161 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 162 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 163 Expect(actualAppName).To(Equal(appName)) 164 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 165 166 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(0)) 167 168 Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) 169 170 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 171 }) 172 }) 173 174 When("getting the app succeeds", func() { 175 BeforeEach(func() { 176 fakeActor.GetApplicationByNameAndSpaceReturns( 177 resources.Application{Name: "app", GUID: "app-guid"}, 178 v7action.Warnings{"get-app-warnings"}, 179 nil, 180 ) 181 }) 182 183 When("getting the route errors", func() { 184 BeforeEach(func() { 185 fakeActor.GetRouteByAttributesReturns( 186 resources.Route{}, 187 v7action.Warnings{"get-route-warnings"}, 188 errors.New("get-route-error"), 189 ) 190 }) 191 192 It("returns the error and displays warnings", func() { 193 Expect(testUI.Err).To(Say("get-domain-warnings")) 194 Expect(testUI.Err).To(Say("get-app-warnings")) 195 Expect(testUI.Err).To(Say("get-route-warnings")) 196 Expect(executeErr).To(MatchError(errors.New("get-route-error"))) 197 198 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 199 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 200 201 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 202 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 203 Expect(actualAppName).To(Equal(appName)) 204 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 205 206 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 207 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 208 Expect(actualDomain.Name).To(Equal("some-domain.com")) 209 Expect(actualDomain.GUID).To(Equal("domain-guid")) 210 Expect(actualHostname).To(Equal(hostname)) 211 Expect(actualPath).To(Equal(path)) 212 Expect(actualPort).To(Equal(cmd.Port)) 213 214 Expect(fakeActor.CreateRouteCallCount()).To(Equal(0)) 215 216 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 217 }) 218 }) 219 220 When("the requested route does not exist", func() { 221 BeforeEach(func() { 222 fakeActor.GetRouteByAttributesReturns( 223 resources.Route{}, 224 v7action.Warnings{"get-route-warnings"}, 225 actionerror.RouteNotFoundError{}, 226 ) 227 }) 228 229 It("creates the route", func() { 230 Expect(testUI.Err).To(Say("get-domain-warnings")) 231 Expect(testUI.Err).To(Say("get-app-warnings")) 232 Expect(testUI.Err).To(Say("get-route-warnings")) 233 Expect(executeErr).ToNot(HaveOccurred()) 234 235 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 236 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 237 238 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 239 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 240 Expect(actualAppName).To(Equal(appName)) 241 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 242 243 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 244 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 245 Expect(actualDomain.Name).To(Equal("some-domain.com")) 246 Expect(actualDomain.GUID).To(Equal("domain-guid")) 247 Expect(actualHostname).To(Equal(hostname)) 248 Expect(actualPath).To(Equal(path)) 249 Expect(actualPort).To(Equal(cmd.Port)) 250 251 Expect(fakeActor.CreateRouteCallCount()).To(Equal(1)) 252 actualSpaceGUID, actualDomainName, actualHostname, actualPath, actualPort := fakeActor.CreateRouteArgsForCall(0) 253 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 254 Expect(actualDomainName).To(Equal("some-domain.com")) 255 Expect(actualHostname).To(Equal(hostname)) 256 Expect(actualPath).To(Equal(path)) 257 Expect(actualPort).To(Equal(cmd.Port)) 258 }) 259 }) 260 261 When("the requested route exists", func() { 262 BeforeEach(func() { 263 fakeActor.GetRouteByAttributesReturns( 264 resources.Route{GUID: "route-guid"}, 265 v7action.Warnings{"get-route-warnings"}, 266 nil, 267 ) 268 }) 269 270 When("getting the destination errors", func() { 271 BeforeEach(func() { 272 fakeActor.GetRouteDestinationByAppGUIDReturns( 273 resources.RouteDestination{}, 274 errors.New("get-destination-error"), 275 ) 276 }) 277 It("returns the error and warnings", func() { 278 Expect(executeErr).To(MatchError(errors.New("get-destination-error"))) 279 280 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 281 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 282 283 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 284 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 285 Expect(actualAppName).To(Equal(appName)) 286 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 287 288 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 289 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 290 Expect(actualDomain.Name).To(Equal("some-domain.com")) 291 Expect(actualDomain.GUID).To(Equal("domain-guid")) 292 Expect(actualHostname).To(Equal(hostname)) 293 Expect(actualPath).To(Equal(path)) 294 Expect(actualPort).To(Equal(cmd.Port)) 295 296 Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(1)) 297 actualRoute, actualAppGUID := fakeActor.GetRouteDestinationByAppGUIDArgsForCall(0) 298 Expect(actualRoute.GUID).To(Equal("route-guid")) 299 Expect(actualAppGUID).To(Equal("app-guid")) 300 301 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 302 }) 303 }) 304 305 When("the destination already exists", func() { 306 BeforeEach(func() { 307 fakeActor.GetRouteDestinationByAppGUIDReturns( 308 resources.RouteDestination{ 309 GUID: "route-dst-guid", 310 App: resources.RouteDestinationApp{ 311 GUID: "existing-app-guid", 312 }, 313 }, 314 nil, 315 ) 316 }) 317 It("exits 0 with a helpful message that the route is already mapped to the app", func() { 318 Expect(executeErr).ShouldNot(HaveOccurred()) 319 320 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 321 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 322 323 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 324 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 325 Expect(actualAppName).To(Equal(appName)) 326 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 327 328 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 329 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 330 Expect(actualDomain.Name).To(Equal("some-domain.com")) 331 Expect(actualDomain.GUID).To(Equal("domain-guid")) 332 Expect(actualHostname).To(Equal(hostname)) 333 Expect(actualPath).To(Equal(path)) 334 Expect(actualPort).To(Equal(cmd.Port)) 335 336 Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(1)) 337 actualRoute, actualAppGUID := fakeActor.GetRouteDestinationByAppGUIDArgsForCall(0) 338 Expect(actualRoute.GUID).To(Equal("route-guid")) 339 Expect(actualAppGUID).To(Equal("app-guid")) 340 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 341 }) 342 343 }) 344 When("the destination is not found", func() { 345 When("mapping the route errors", func() { 346 BeforeEach(func() { 347 fakeActor.MapRouteReturns(v7action.Warnings{"map-route-warnings"}, errors.New("map-route-error")) 348 }) 349 350 It("returns the error and displays warnings", func() { 351 Expect(testUI.Err).To(Say("get-domain-warnings")) 352 Expect(testUI.Err).To(Say("get-app-warnings")) 353 Expect(testUI.Err).To(Say("get-route-warnings")) 354 Expect(testUI.Err).To(Say("map-route-warnings")) 355 Expect(executeErr).To(MatchError(errors.New("map-route-error"))) 356 357 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 358 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 359 360 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 361 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 362 Expect(actualAppName).To(Equal(appName)) 363 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 364 365 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 366 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 367 Expect(actualDomain.Name).To(Equal("some-domain.com")) 368 Expect(actualDomain.GUID).To(Equal("domain-guid")) 369 Expect(actualHostname).To(Equal(hostname)) 370 Expect(actualPath).To(Equal(path)) 371 Expect(actualPort).To(Equal(cmd.Port)) 372 373 Expect(fakeActor.MapRouteCallCount()).To(Equal(1)) 374 actualRouteGUID, actualAppGUID := fakeActor.MapRouteArgsForCall(0) 375 Expect(actualRouteGUID).To(Equal("route-guid")) 376 Expect(actualAppGUID).To(Equal("app-guid")) 377 }) 378 }) 379 380 When("mapping the route succeeds", func() { 381 BeforeEach(func() { 382 fakeActor.MapRouteReturns(v7action.Warnings{"map-route-warnings"}, nil) 383 }) 384 385 It("returns the proper information and passing the proper arguments", func() { 386 By("displaying warnings", func() { 387 Expect(testUI.Err).To(Say("get-domain-warnings")) 388 Expect(testUI.Err).To(Say("get-app-warnings")) 389 Expect(testUI.Err).To(Say("get-route-warnings")) 390 Expect(testUI.Err).To(Say("map-route-warnings")) 391 Expect(executeErr).ToNot(HaveOccurred()) 392 }) 393 394 By("passing the expected arguments to the actor ", func() { 395 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 396 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 397 398 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 399 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 400 Expect(actualAppName).To(Equal(appName)) 401 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 402 403 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 404 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 405 Expect(actualDomain.Name).To(Equal("some-domain.com")) 406 Expect(actualDomain.GUID).To(Equal("domain-guid")) 407 Expect(actualHostname).To(Equal("host")) 408 Expect(actualPath).To(Equal(path)) 409 Expect(actualPort).To(Equal(cmd.Port)) 410 411 Expect(fakeActor.MapRouteCallCount()).To(Equal(1)) 412 actualRouteGUID, actualAppGUID := fakeActor.MapRouteArgsForCall(0) 413 Expect(actualRouteGUID).To(Equal("route-guid")) 414 Expect(actualAppGUID).To(Equal("app-guid")) 415 }) 416 }) 417 }) 418 }) 419 }) 420 421 When("a tcp route is requested without a port", func() { 422 BeforeEach(func() { 423 fakeActor.GetRouteByAttributesReturns( 424 resources.Route{GUID: "route-guid"}, 425 v7action.Warnings{"get-route-warnings"}, 426 nil, 427 ) 428 }) 429 430 When("getting the destination errors", func() { 431 BeforeEach(func() { 432 fakeActor.GetRouteDestinationByAppGUIDReturns( 433 resources.RouteDestination{}, 434 errors.New("get-destination-error"), 435 ) 436 }) 437 It("returns the error and warnings", func() { 438 Expect(executeErr).To(MatchError(errors.New("get-destination-error"))) 439 440 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 441 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 442 443 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 444 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 445 Expect(actualAppName).To(Equal(appName)) 446 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 447 448 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 449 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 450 Expect(actualDomain.Name).To(Equal("some-domain.com")) 451 Expect(actualDomain.GUID).To(Equal("domain-guid")) 452 Expect(actualHostname).To(Equal(hostname)) 453 Expect(actualPath).To(Equal(path)) 454 Expect(actualPort).To(Equal(cmd.Port)) 455 456 Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(1)) 457 actualRoute, actualAppGUID := fakeActor.GetRouteDestinationByAppGUIDArgsForCall(0) 458 Expect(actualRoute.GUID).To(Equal("route-guid")) 459 Expect(actualAppGUID).To(Equal("app-guid")) 460 461 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 462 }) 463 }) 464 465 When("the destination already exists", func() { 466 BeforeEach(func() { 467 fakeActor.GetRouteDestinationByAppGUIDReturns( 468 resources.RouteDestination{ 469 GUID: "route-dst-guid", 470 App: resources.RouteDestinationApp{ 471 GUID: "existing-app-guid", 472 }, 473 }, 474 nil, 475 ) 476 }) 477 It("exits 0 with a helpful message that the route is already mapped to the app", func() { 478 Expect(executeErr).ShouldNot(HaveOccurred()) 479 480 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 481 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 482 483 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 484 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 485 Expect(actualAppName).To(Equal(appName)) 486 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 487 488 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 489 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 490 Expect(actualDomain.Name).To(Equal("some-domain.com")) 491 Expect(actualDomain.GUID).To(Equal("domain-guid")) 492 Expect(actualHostname).To(Equal(hostname)) 493 Expect(actualPath).To(Equal(path)) 494 Expect(actualPort).To(Equal(cmd.Port)) 495 496 Expect(fakeActor.GetRouteDestinationByAppGUIDCallCount()).To(Equal(1)) 497 actualRoute, actualAppGUID := fakeActor.GetRouteDestinationByAppGUIDArgsForCall(0) 498 Expect(actualRoute.GUID).To(Equal("route-guid")) 499 Expect(actualAppGUID).To(Equal("app-guid")) 500 Expect(fakeActor.MapRouteCallCount()).To(Equal(0)) 501 }) 502 503 }) 504 When("the destination is not found", func() { 505 When("mapping the route errors", func() { 506 BeforeEach(func() { 507 fakeActor.MapRouteReturns(v7action.Warnings{"map-route-warnings"}, errors.New("map-route-error")) 508 }) 509 510 It("returns the error and displays warnings", func() { 511 Expect(testUI.Err).To(Say("get-domain-warnings")) 512 Expect(testUI.Err).To(Say("get-app-warnings")) 513 Expect(testUI.Err).To(Say("get-route-warnings")) 514 Expect(testUI.Err).To(Say("map-route-warnings")) 515 Expect(executeErr).To(MatchError(errors.New("map-route-error"))) 516 517 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 518 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 519 520 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 521 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 522 Expect(actualAppName).To(Equal(appName)) 523 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 524 525 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 526 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 527 Expect(actualDomain.Name).To(Equal("some-domain.com")) 528 Expect(actualDomain.GUID).To(Equal("domain-guid")) 529 Expect(actualHostname).To(Equal(hostname)) 530 Expect(actualPath).To(Equal(path)) 531 Expect(actualPort).To(Equal(cmd.Port)) 532 533 Expect(fakeActor.MapRouteCallCount()).To(Equal(1)) 534 actualRouteGUID, actualAppGUID := fakeActor.MapRouteArgsForCall(0) 535 Expect(actualRouteGUID).To(Equal("route-guid")) 536 Expect(actualAppGUID).To(Equal("app-guid")) 537 }) 538 }) 539 540 When("mapping the route succeeds", func() { 541 BeforeEach(func() { 542 fakeActor.MapRouteReturns(v7action.Warnings{"map-route-warnings"}, nil) 543 }) 544 545 It("returns the proper information and passing the proper arguments", func() { 546 By("displaying warnings", func() { 547 Expect(testUI.Err).To(Say("get-domain-warnings")) 548 Expect(testUI.Err).To(Say("get-app-warnings")) 549 Expect(testUI.Err).To(Say("get-route-warnings")) 550 Expect(testUI.Err).To(Say("map-route-warnings")) 551 Expect(executeErr).ToNot(HaveOccurred()) 552 }) 553 554 By("passing the expected arguments to the actor ", func() { 555 Expect(fakeActor.GetDomainByNameCallCount()).To(Equal(1)) 556 Expect(fakeActor.GetDomainByNameArgsForCall(0)).To(Equal(domain)) 557 558 Expect(fakeActor.GetApplicationByNameAndSpaceCallCount()).To(Equal(1)) 559 actualAppName, actualSpaceGUID := fakeActor.GetApplicationByNameAndSpaceArgsForCall(0) 560 Expect(actualAppName).To(Equal(appName)) 561 Expect(actualSpaceGUID).To(Equal(spaceGUID)) 562 563 Expect(fakeActor.GetRouteByAttributesCallCount()).To(Equal(1)) 564 actualDomain, actualHostname, actualPath, actualPort := fakeActor.GetRouteByAttributesArgsForCall(0) 565 Expect(actualDomain.Name).To(Equal("some-domain.com")) 566 Expect(actualDomain.GUID).To(Equal("domain-guid")) 567 Expect(actualHostname).To(Equal("host")) 568 Expect(actualPath).To(Equal(path)) 569 Expect(actualPort).To(Equal(cmd.Port)) 570 571 Expect(fakeActor.MapRouteCallCount()).To(Equal(1)) 572 actualRouteGUID, actualAppGUID := fakeActor.MapRouteArgsForCall(0) 573 Expect(actualRouteGUID).To(Equal("route-guid")) 574 Expect(actualAppGUID).To(Equal("app-guid")) 575 }) 576 }) 577 }) 578 }) 579 }) 580 }) 581 }) 582 }) 583 })