github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/pushaction/route_test.go (about) 1 package pushaction_test 2 3 import ( 4 "errors" 5 6 . "code.cloudfoundry.org/cli/actor/pushaction" 7 "code.cloudfoundry.org/cli/actor/pushaction/pushactionfakes" 8 "code.cloudfoundry.org/cli/actor/v2action" 9 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("Routes", func() { 15 var ( 16 actor *Actor 17 fakeV2Actor *pushactionfakes.FakeV2Actor 18 ) 19 20 BeforeEach(func() { 21 fakeV2Actor = new(pushactionfakes.FakeV2Actor) 22 actor = NewActor(fakeV2Actor) 23 }) 24 25 Describe("CreateRoutes", func() { 26 var ( 27 config ApplicationConfig 28 29 returnedConfig ApplicationConfig 30 createdRoutes bool 31 warnings Warnings 32 executeErr error 33 ) 34 35 BeforeEach(func() { 36 config = ApplicationConfig{} 37 }) 38 39 JustBeforeEach(func() { 40 returnedConfig, createdRoutes, warnings, executeErr = actor.CreateRoutes(config) 41 }) 42 43 Describe("when routes need to be created", func() { 44 BeforeEach(func() { 45 config.DesiredRoutes = []v2action.Route{ 46 {GUID: "", Host: "some-route-1"}, 47 {GUID: "some-route-guid-2", Host: "some-route-2"}, 48 {GUID: "", Host: "some-route-3"}, 49 } 50 }) 51 52 Context("when the creation is successful", func() { 53 BeforeEach(func() { 54 fakeV2Actor.CreateRouteReturnsOnCall(0, v2action.Route{GUID: "some-route-guid-1", Host: "some-route-1"}, v2action.Warnings{"create-route-warning"}, nil) 55 fakeV2Actor.CreateRouteReturnsOnCall(1, v2action.Route{GUID: "some-route-guid-3", Host: "some-route-3"}, v2action.Warnings{"create-route-warning"}, nil) 56 }) 57 58 It("only creates the routes that do not exist", func() { 59 Expect(executeErr).ToNot(HaveOccurred()) 60 Expect(warnings).To(ConsistOf("create-route-warning", "create-route-warning")) 61 Expect(createdRoutes).To(BeTrue()) 62 Expect(returnedConfig.DesiredRoutes).To(Equal([]v2action.Route{ 63 {GUID: "some-route-guid-1", Host: "some-route-1"}, 64 {GUID: "some-route-guid-2", Host: "some-route-2"}, 65 {GUID: "some-route-guid-3", Host: "some-route-3"}, 66 })) 67 68 Expect(fakeV2Actor.CreateRouteCallCount()).To(Equal(2)) 69 Expect(fakeV2Actor.CreateRouteArgsForCall(0)).To(Equal(v2action.Route{Host: "some-route-1"})) 70 Expect(fakeV2Actor.CreateRouteArgsForCall(1)).To(Equal(v2action.Route{Host: "some-route-3"})) 71 }) 72 }) 73 74 Context("when the creation errors", func() { 75 var expectedErr error 76 77 BeforeEach(func() { 78 expectedErr = errors.New("oh my") 79 fakeV2Actor.CreateRouteReturns( 80 v2action.Route{}, 81 v2action.Warnings{"create-route-warning"}, 82 expectedErr) 83 }) 84 85 It("sends the warnings and errors and returns true", func() { 86 Expect(executeErr).To(MatchError(expectedErr)) 87 Expect(warnings).To(ConsistOf("create-route-warning")) 88 }) 89 }) 90 }) 91 92 Context("when no routes are created", func() { 93 BeforeEach(func() { 94 config.DesiredRoutes = []v2action.Route{ 95 {GUID: "some-route-guid-1", Host: "some-route-1"}, 96 {GUID: "some-route-guid-2", Host: "some-route-2"}, 97 {GUID: "some-route-guid-3", Host: "some-route-3"}, 98 } 99 }) 100 101 It("returns false", func() { 102 Expect(createdRoutes).To(BeFalse()) 103 }) 104 }) 105 }) 106 107 Describe("BindRoutes", func() { 108 var ( 109 config ApplicationConfig 110 111 returnedConfig ApplicationConfig 112 boundRoutes bool 113 warnings Warnings 114 executeErr error 115 ) 116 117 BeforeEach(func() { 118 config = ApplicationConfig{ 119 DesiredApplication: v2action.Application{ 120 GUID: "some-app-guid", 121 }, 122 } 123 }) 124 125 JustBeforeEach(func() { 126 returnedConfig, boundRoutes, warnings, executeErr = actor.BindRoutes(config) 127 }) 128 129 Context("when routes need to be bound to the application", func() { 130 BeforeEach(func() { 131 config.CurrentRoutes = []v2action.Route{ 132 {GUID: "some-route-guid-2", Host: "some-route-2"}, 133 } 134 config.DesiredRoutes = []v2action.Route{ 135 {GUID: "some-route-guid-1", Host: "some-route-1", Domain: v2action.Domain{Name: "some-domain.com"}}, 136 {GUID: "some-route-guid-2", Host: "some-route-2"}, 137 {GUID: "some-route-guid-3", Host: "some-route-3"}, 138 } 139 }) 140 141 Context("when the binding is successful", func() { 142 BeforeEach(func() { 143 fakeV2Actor.BindRouteToApplicationReturns(v2action.Warnings{"bind-route-warning"}, nil) 144 }) 145 146 It("only creates the routes that do not exist", func() { 147 Expect(executeErr).ToNot(HaveOccurred()) 148 Expect(warnings).To(ConsistOf("bind-route-warning", "bind-route-warning")) 149 Expect(boundRoutes).To(BeTrue()) 150 151 Expect(returnedConfig.CurrentRoutes).To(Equal(config.DesiredRoutes)) 152 153 Expect(fakeV2Actor.BindRouteToApplicationCallCount()).To(Equal(2)) 154 155 routeGUID, appGUID := fakeV2Actor.BindRouteToApplicationArgsForCall(0) 156 Expect(routeGUID).To(Equal("some-route-guid-1")) 157 Expect(appGUID).To(Equal("some-app-guid")) 158 159 routeGUID, appGUID = fakeV2Actor.BindRouteToApplicationArgsForCall(1) 160 Expect(routeGUID).To(Equal("some-route-guid-3")) 161 Expect(appGUID).To(Equal("some-app-guid")) 162 }) 163 }) 164 165 Context("when the binding errors", func() { 166 Context("when the route is bound in another space", func() { 167 BeforeEach(func() { 168 fakeV2Actor.BindRouteToApplicationReturns(v2action.Warnings{"bind-route-warning"}, v2action.RouteInDifferentSpaceError{}) 169 }) 170 171 It("sends the RouteInDifferentSpaceError (with a guid set) and warnings and returns true", func() { 172 Expect(executeErr).To(MatchError(v2action.RouteInDifferentSpaceError{Route: "some-route-1.some-domain.com"})) 173 Expect(warnings).To(ConsistOf("bind-route-warning")) 174 }) 175 }) 176 177 Context("generic error", func() { 178 var expectedErr error 179 BeforeEach(func() { 180 expectedErr = errors.New("oh my") 181 fakeV2Actor.BindRouteToApplicationReturns(v2action.Warnings{"bind-route-warning"}, expectedErr) 182 }) 183 184 It("sends the warnings and errors and returns true", func() { 185 Expect(executeErr).To(MatchError(expectedErr)) 186 Expect(warnings).To(ConsistOf("bind-route-warning")) 187 }) 188 }) 189 }) 190 }) 191 192 Context("when no routes need to be bound", func() { 193 It("returns false", func() { 194 Expect(executeErr).ToNot(HaveOccurred()) 195 }) 196 }) 197 }) 198 199 Describe("CreateAndBindApplicationRoutes", func() { 200 var ( 201 warnings Warnings 202 executeErr error 203 ) 204 205 JustBeforeEach(func() { 206 warnings, executeErr = actor.CreateAndBindApplicationRoutes("some-org-guid", "some-space-guid", 207 v2action.Application{Name: "some-app", GUID: "some-app-guid"}) 208 }) 209 210 Context("when getting organization domains errors", func() { 211 BeforeEach(func() { 212 fakeV2Actor.GetOrganizationDomainsReturns( 213 []v2action.Domain{}, 214 v2action.Warnings{"domain-warning"}, 215 errors.New("some-error")) 216 }) 217 218 It("returns the error", func() { 219 Expect(executeErr).To(MatchError("some-error")) 220 Expect(warnings).To(ConsistOf("domain-warning")) 221 }) 222 }) 223 224 Context("when getting organization domains succeeds", func() { 225 BeforeEach(func() { 226 fakeV2Actor.GetOrganizationDomainsReturns( 227 []v2action.Domain{ 228 { 229 GUID: "some-domain-guid", 230 Name: "some-domain", 231 }, 232 }, 233 v2action.Warnings{"domain-warning"}, 234 nil, 235 ) 236 }) 237 238 Context("when getting the application routes errors", func() { 239 BeforeEach(func() { 240 fakeV2Actor.GetApplicationRoutesReturns( 241 []v2action.Route{}, 242 v2action.Warnings{"route-warning"}, 243 errors.New("some-error"), 244 ) 245 }) 246 247 It("returns the error", func() { 248 Expect(executeErr).To(MatchError("some-error")) 249 Expect(warnings).To(ConsistOf("domain-warning", "route-warning")) 250 }) 251 }) 252 253 Context("when getting the application routes succeeds", func() { 254 // TODO: do we need this context 255 Context("when the route is already bound to the app", func() { 256 BeforeEach(func() { 257 fakeV2Actor.GetApplicationRoutesReturns( 258 []v2action.Route{ 259 { 260 Host: "some-app", 261 Domain: v2action.Domain{ 262 GUID: "some-domain-guid", 263 Name: "some-domain", 264 }, 265 GUID: "some-route-guid", 266 SpaceGUID: "some-space-guid", 267 }, 268 }, 269 v2action.Warnings{"route-warning"}, 270 nil, 271 ) 272 }) 273 274 It("returns any warnings", func() { 275 Expect(executeErr).ToNot(HaveOccurred()) 276 Expect(warnings).To(ConsistOf("domain-warning", "route-warning")) 277 278 Expect(fakeV2Actor.GetOrganizationDomainsCallCount()).To(Equal(1), "Expected GetOrganizationDomains to be called once, but it was not") 279 orgGUID := fakeV2Actor.GetOrganizationDomainsArgsForCall(0) 280 Expect(orgGUID).To(Equal("some-org-guid")) 281 282 Expect(fakeV2Actor.GetApplicationRoutesCallCount()).To(Equal(1), "Expected GetApplicationRoutes to be called once, but it was not") 283 appGUID := fakeV2Actor.GetApplicationRoutesArgsForCall(0) 284 Expect(appGUID).To(Equal("some-app-guid")) 285 286 Expect(fakeV2Actor.CreateRouteCallCount()).To(Equal(0), "Expected CreateRoute to not be called but it was") 287 Expect(fakeV2Actor.BindRouteToApplicationCallCount()).To(Equal(0), "Expected BindRouteToApplication to not be called but it was") 288 }) 289 }) 290 291 Context("when the route isn't bound to the app", func() { 292 Context("when finding route in space errors", func() { 293 BeforeEach(func() { 294 fakeV2Actor.FindRouteBoundToSpaceWithSettingsReturns( 295 v2action.Route{}, 296 v2action.Warnings{"route-warning"}, 297 errors.New("some-error"), 298 ) 299 }) 300 301 It("returns the error", func() { 302 Expect(executeErr).To(MatchError("some-error")) 303 Expect(warnings).To(ConsistOf("domain-warning", "route-warning")) 304 }) 305 }) 306 307 Context("when the route exists", func() { 308 BeforeEach(func() { 309 fakeV2Actor.FindRouteBoundToSpaceWithSettingsReturns( 310 v2action.Route{ 311 GUID: "some-route-guid", 312 Host: "some-app", 313 Domain: v2action.Domain{ 314 Name: "some-domain", 315 GUID: "some-domain-guid", 316 }, 317 SpaceGUID: "some-space-guid", 318 }, 319 v2action.Warnings{"route-warning"}, 320 nil, 321 ) 322 }) 323 324 Context("when the bind command returns an error", func() { 325 BeforeEach(func() { 326 fakeV2Actor.BindRouteToApplicationReturns( 327 v2action.Warnings{"bind-warning"}, 328 errors.New("some-error"), 329 ) 330 }) 331 332 It("returns the error", func() { 333 Expect(executeErr).To(MatchError("some-error")) 334 Expect(warnings).To(ConsistOf("domain-warning", "route-warning", "bind-warning")) 335 }) 336 }) 337 338 Context("when the bind command succeeds", func() { 339 BeforeEach(func() { 340 fakeV2Actor.BindRouteToApplicationReturns( 341 v2action.Warnings{"bind-warning"}, 342 nil, 343 ) 344 }) 345 346 It("binds the route to the app and returns any warnings", func() { 347 Expect(executeErr).ToNot(HaveOccurred()) 348 Expect(warnings).To(ConsistOf("domain-warning", "route-warning", "bind-warning")) 349 350 Expect(fakeV2Actor.FindRouteBoundToSpaceWithSettingsCallCount()).To(Equal(1), "Expected FindRouteBoundToSpaceWithSettings to be called once, but it was not") 351 spaceRoute := fakeV2Actor.FindRouteBoundToSpaceWithSettingsArgsForCall(0) 352 Expect(spaceRoute).To(Equal(v2action.Route{ 353 Host: "some-app", 354 Domain: v2action.Domain{ 355 Name: "some-domain", 356 GUID: "some-domain-guid", 357 }, 358 SpaceGUID: "some-space-guid", 359 })) 360 361 Expect(fakeV2Actor.BindRouteToApplicationCallCount()).To(Equal(1), "Expected BindRouteToApplication to be called once, but it was not") 362 routeGUID, appGUID := fakeV2Actor.BindRouteToApplicationArgsForCall(0) 363 Expect(routeGUID).To(Equal("some-route-guid")) 364 Expect(appGUID).To(Equal("some-app-guid")) 365 }) 366 }) 367 }) 368 369 Context("when the route does not exist", func() { 370 BeforeEach(func() { 371 fakeV2Actor.FindRouteBoundToSpaceWithSettingsReturns( 372 v2action.Route{}, 373 v2action.Warnings{"route-warning"}, 374 v2action.RouteNotFoundError{}, 375 ) 376 }) 377 378 Context("when the create route command errors", func() { 379 BeforeEach(func() { 380 fakeV2Actor.CreateRouteReturns( 381 v2action.Route{}, 382 v2action.Warnings{"route-create-warning"}, 383 errors.New("some-error"), 384 ) 385 }) 386 387 It("returns the error", func() { 388 Expect(executeErr).To(MatchError("some-error")) 389 Expect(warnings).To(ConsistOf("domain-warning", "route-warning", "route-create-warning")) 390 }) 391 }) 392 393 Context("when the create route command succeeds", func() { 394 BeforeEach(func() { 395 fakeV2Actor.CreateRouteReturns( 396 v2action.Route{ 397 GUID: "some-route-guid", 398 Host: "some-app", 399 Domain: v2action.Domain{ 400 Name: "some-domain", 401 GUID: "some-domain-guid", 402 }, 403 SpaceGUID: "some-space-guid", 404 }, 405 v2action.Warnings{"route-create-warning"}, 406 nil, 407 ) 408 }) 409 410 Context("when the bind command errors", func() { 411 BeforeEach(func() { 412 fakeV2Actor.BindRouteToApplicationReturns( 413 v2action.Warnings{"bind-warning"}, 414 errors.New("some-error"), 415 ) 416 }) 417 418 It("returns the error", func() { 419 Expect(executeErr).To(MatchError("some-error")) 420 Expect(warnings).To(ConsistOf("domain-warning", "route-warning", "route-create-warning", "bind-warning")) 421 }) 422 }) 423 Context("when the bind command succeeds", func() { 424 425 BeforeEach(func() { 426 fakeV2Actor.BindRouteToApplicationReturns( 427 v2action.Warnings{"bind-warning"}, 428 nil, 429 ) 430 }) 431 432 It("creates the route, binds it to the app, and returns any warnings", func() { 433 Expect(executeErr).ToNot(HaveOccurred()) 434 Expect(warnings).To(ConsistOf("domain-warning", "route-warning", "route-create-warning", "bind-warning")) 435 436 Expect(fakeV2Actor.CreateRouteCallCount()).To(Equal(1), "Expected CreateRoute to be called once, but it was not") 437 defaultRoute, shouldGeneratePort := fakeV2Actor.CreateRouteArgsForCall(0) 438 Expect(defaultRoute).To(Equal(v2action.Route{ 439 Host: "some-app", 440 Domain: v2action.Domain{ 441 Name: "some-domain", 442 GUID: "some-domain-guid", 443 }, 444 SpaceGUID: "some-space-guid", 445 })) 446 Expect(shouldGeneratePort).To(BeFalse()) 447 448 Expect(fakeV2Actor.FindRouteBoundToSpaceWithSettingsCallCount()).To(Equal(1), "Expected FindRouteBoundToSpaceWithSettings to be called once, but it was not") 449 spaceRoute := fakeV2Actor.FindRouteBoundToSpaceWithSettingsArgsForCall(0) 450 Expect(spaceRoute).To(Equal(v2action.Route{ 451 Host: "some-app", 452 Domain: v2action.Domain{ 453 Name: "some-domain", 454 GUID: "some-domain-guid", 455 }, 456 SpaceGUID: "some-space-guid", 457 })) 458 459 Expect(fakeV2Actor.BindRouteToApplicationCallCount()).To(Equal(1), "Expected BindRouteToApplication to be called once, but it was not") 460 routeGUID, appGUID := fakeV2Actor.BindRouteToApplicationArgsForCall(0) 461 Expect(routeGUID).To(Equal("some-route-guid")) 462 Expect(appGUID).To(Equal("some-app-guid")) 463 }) 464 }) 465 }) 466 }) 467 }) 468 }) 469 }) 470 }) 471 472 Describe("CreateRoutes", func() { 473 var ( 474 config ApplicationConfig 475 476 returnedConfig ApplicationConfig 477 createdRoutes bool 478 warnings Warnings 479 executeErr error 480 ) 481 482 BeforeEach(func() { 483 config = ApplicationConfig{} 484 }) 485 486 JustBeforeEach(func() { 487 returnedConfig, createdRoutes, warnings, executeErr = actor.CreateRoutes(config) 488 }) 489 490 Describe("when routes need to be created", func() { 491 BeforeEach(func() { 492 config.DesiredRoutes = []v2action.Route{ 493 {GUID: "", Host: "some-route-1"}, 494 {GUID: "some-route-guid-2", Host: "some-route-2"}, 495 {GUID: "", Host: "some-route-3"}, 496 } 497 }) 498 499 Context("when the creation is successful", func() { 500 BeforeEach(func() { 501 fakeV2Actor.CreateRouteReturnsOnCall(0, v2action.Route{GUID: "some-route-guid-1", Host: "some-route-1"}, v2action.Warnings{"create-route-warning"}, nil) 502 fakeV2Actor.CreateRouteReturnsOnCall(1, v2action.Route{GUID: "some-route-guid-3", Host: "some-route-3"}, v2action.Warnings{"create-route-warning"}, nil) 503 }) 504 505 It("only creates the routes that do not exist", func() { 506 Expect(executeErr).ToNot(HaveOccurred()) 507 Expect(warnings).To(ConsistOf("create-route-warning", "create-route-warning")) 508 Expect(createdRoutes).To(BeTrue()) 509 Expect(returnedConfig.DesiredRoutes).To(Equal([]v2action.Route{ 510 {GUID: "some-route-guid-1", Host: "some-route-1"}, 511 {GUID: "some-route-guid-2", Host: "some-route-2"}, 512 {GUID: "some-route-guid-3", Host: "some-route-3"}, 513 })) 514 515 Expect(fakeV2Actor.CreateRouteCallCount()).To(Equal(2)) 516 Expect(fakeV2Actor.CreateRouteArgsForCall(0)).To(Equal(v2action.Route{Host: "some-route-1"})) 517 Expect(fakeV2Actor.CreateRouteArgsForCall(1)).To(Equal(v2action.Route{Host: "some-route-3"})) 518 }) 519 }) 520 521 Context("when the creation errors", func() { 522 var expectedErr error 523 524 BeforeEach(func() { 525 expectedErr = errors.New("oh my") 526 fakeV2Actor.CreateRouteReturns( 527 v2action.Route{}, 528 v2action.Warnings{"create-route-warning"}, 529 expectedErr) 530 }) 531 532 It("sends the warnings and errors and returns true", func() { 533 Expect(executeErr).To(MatchError(expectedErr)) 534 Expect(warnings).To(ConsistOf("create-route-warning")) 535 }) 536 }) 537 }) 538 539 Context("when no routes are created", func() { 540 BeforeEach(func() { 541 config.DesiredRoutes = []v2action.Route{ 542 {GUID: "some-route-guid-1", Host: "some-route-1"}, 543 {GUID: "some-route-guid-2", Host: "some-route-2"}, 544 {GUID: "some-route-guid-3", Host: "some-route-3"}, 545 } 546 }) 547 548 It("returns false", func() { 549 Expect(createdRoutes).To(BeFalse()) 550 }) 551 }) 552 }) 553 554 Describe("GetRouteWithDefaultDomain", func() { 555 var ( 556 host string 557 orgGUID string 558 spaceGUID string 559 knownRoutes []v2action.Route 560 561 defaultRoute v2action.Route 562 warnings Warnings 563 executeErr error 564 565 domain v2action.Domain 566 ) 567 568 BeforeEach(func() { 569 host = "some-app" 570 orgGUID = "some-org-guid" 571 spaceGUID = "some-space-guid" 572 knownRoutes = nil 573 574 domain = v2action.Domain{ 575 Name: "private-domain.com", 576 GUID: "some-private-domain-guid", 577 } 578 }) 579 580 JustBeforeEach(func() { 581 defaultRoute, warnings, executeErr = actor.GetRouteWithDefaultDomain(host, orgGUID, spaceGUID, knownRoutes) 582 }) 583 584 Context("when retrieving the domains is successful", func() { 585 BeforeEach(func() { 586 fakeV2Actor.GetOrganizationDomainsReturns( 587 []v2action.Domain{domain}, 588 v2action.Warnings{"private-domain-warnings", "shared-domain-warnings"}, 589 nil, 590 ) 591 }) 592 593 Context("when the route exists", func() { 594 BeforeEach(func() { 595 // Assumes new route 596 fakeV2Actor.FindRouteBoundToSpaceWithSettingsReturns(v2action.Route{ 597 Domain: domain, 598 GUID: "some-route-guid", 599 Host: host, 600 SpaceGUID: spaceGUID, 601 }, v2action.Warnings{"get-route-warnings"}, nil) 602 }) 603 604 It("returns the route and warnings", func() { 605 Expect(executeErr).ToNot(HaveOccurred()) 606 Expect(warnings).To(ConsistOf("private-domain-warnings", "shared-domain-warnings", "get-route-warnings")) 607 608 Expect(defaultRoute).To(Equal(v2action.Route{ 609 Domain: domain, 610 GUID: "some-route-guid", 611 Host: host, 612 SpaceGUID: spaceGUID, 613 })) 614 615 Expect(fakeV2Actor.GetOrganizationDomainsCallCount()).To(Equal(1)) 616 Expect(fakeV2Actor.GetOrganizationDomainsArgsForCall(0)).To(Equal(orgGUID)) 617 618 Expect(fakeV2Actor.FindRouteBoundToSpaceWithSettingsCallCount()).To(Equal(1)) 619 Expect(fakeV2Actor.FindRouteBoundToSpaceWithSettingsArgsForCall(0)).To(Equal(v2action.Route{Domain: domain, Host: host, SpaceGUID: spaceGUID})) 620 }) 621 622 Context("when the route has been found", func() { 623 BeforeEach(func() { 624 knownRoutes = []v2action.Route{{ 625 Domain: domain, 626 GUID: "some-route-guid", 627 Host: host, 628 SpaceGUID: spaceGUID, 629 }} 630 }) 631 632 It("should return the known route and warnings", func() { 633 Expect(executeErr).ToNot(HaveOccurred()) 634 Expect(warnings).To(ConsistOf("private-domain-warnings", "shared-domain-warnings")) 635 636 Expect(defaultRoute).To(Equal(v2action.Route{ 637 Domain: domain, 638 GUID: "some-route-guid", 639 Host: host, 640 SpaceGUID: spaceGUID, 641 })) 642 643 Expect(fakeV2Actor.FindRouteBoundToSpaceWithSettingsCallCount()).To(Equal(0)) 644 }) 645 }) 646 }) 647 648 Context("when the route does not exist", func() { 649 BeforeEach(func() { 650 fakeV2Actor.FindRouteBoundToSpaceWithSettingsReturns(v2action.Route{}, v2action.Warnings{"get-route-warnings"}, v2action.RouteNotFoundError{}) 651 }) 652 653 It("returns a partial route", func() { 654 Expect(executeErr).ToNot(HaveOccurred()) 655 Expect(warnings).To(ConsistOf("private-domain-warnings", "shared-domain-warnings", "get-route-warnings")) 656 657 Expect(defaultRoute).To(Equal(v2action.Route{Domain: domain, Host: host, SpaceGUID: spaceGUID})) 658 }) 659 }) 660 661 Context("when retrieving the routes errors", func() { 662 var expectedErr error 663 664 BeforeEach(func() { 665 expectedErr = errors.New("whoops") 666 fakeV2Actor.FindRouteBoundToSpaceWithSettingsReturns(v2action.Route{}, v2action.Warnings{"get-route-warnings"}, expectedErr) 667 }) 668 669 It("returns errors and warnings", func() { 670 Expect(executeErr).To(MatchError(expectedErr)) 671 Expect(warnings).To(ConsistOf("private-domain-warnings", "shared-domain-warnings", "get-route-warnings")) 672 }) 673 }) 674 }) 675 676 Context("when retrieving the domains errors", func() { 677 var expectedErr error 678 679 BeforeEach(func() { 680 expectedErr = errors.New("whoops") 681 fakeV2Actor.GetOrganizationDomainsReturns([]v2action.Domain{}, v2action.Warnings{"private-domain-warnings", "shared-domain-warnings"}, expectedErr) 682 }) 683 684 It("returns errors and warnings", func() { 685 Expect(executeErr).To(MatchError(expectedErr)) 686 Expect(warnings).To(ConsistOf("private-domain-warnings", "shared-domain-warnings")) 687 }) 688 }) 689 }) 690 })