github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/actor/v2action/organization_test.go (about) 1 package v2action_test 2 3 import ( 4 "errors" 5 6 "code.cloudfoundry.org/cli/actor/actionerror" 7 . "code.cloudfoundry.org/cli/actor/v2action" 8 "code.cloudfoundry.org/cli/actor/v2action/v2actionfakes" 9 "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" 10 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2" 11 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/constant" 12 uaaconst "code.cloudfoundry.org/cli/api/uaa/constant" 13 . "github.com/onsi/ginkgo" 14 . "github.com/onsi/gomega" 15 . "github.com/onsi/gomega/gstruct" 16 ) 17 18 var _ = Describe("Org Actions", func() { 19 var ( 20 actor *Actor 21 fakeCloudControllerClient *v2actionfakes.FakeCloudControllerClient 22 fakeConfig *v2actionfakes.FakeConfig 23 ) 24 25 BeforeEach(func() { 26 fakeCloudControllerClient = new(v2actionfakes.FakeCloudControllerClient) 27 fakeConfig = new(v2actionfakes.FakeConfig) 28 actor = NewActor(fakeCloudControllerClient, nil, fakeConfig) 29 }) 30 31 Describe("GetOrganization", func() { 32 var ( 33 org Organization 34 warnings Warnings 35 err error 36 ) 37 38 JustBeforeEach(func() { 39 org, warnings, err = actor.GetOrganization("some-org-guid") 40 }) 41 42 When("the org exists", func() { 43 BeforeEach(func() { 44 fakeCloudControllerClient.GetOrganizationReturns( 45 ccv2.Organization{ 46 GUID: "some-org-guid", 47 Name: "some-org", 48 QuotaDefinitionGUID: "some-quota-definition-guid", 49 }, 50 ccv2.Warnings{"warning-1", "warning-2"}, 51 nil) 52 }) 53 54 It("returns the org and all warnings", func() { 55 Expect(err).ToNot(HaveOccurred()) 56 57 Expect(org.GUID).To(Equal("some-org-guid")) 58 Expect(org.Name).To(Equal("some-org")) 59 Expect(org.QuotaDefinitionGUID).To(Equal("some-quota-definition-guid")) 60 61 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 62 63 Expect(fakeCloudControllerClient.GetOrganizationCallCount()).To(Equal(1)) 64 guid := fakeCloudControllerClient.GetOrganizationArgsForCall(0) 65 Expect(guid).To(Equal("some-org-guid")) 66 }) 67 }) 68 69 When("the org does not exist", func() { 70 BeforeEach(func() { 71 fakeCloudControllerClient.GetOrganizationReturns( 72 ccv2.Organization{}, 73 ccv2.Warnings{"warning-1", "warning-2"}, 74 ccerror.ResourceNotFoundError{}, 75 ) 76 }) 77 78 It("returns warnings and OrganizationNotFoundError", func() { 79 Expect(err).To(MatchError(actionerror.OrganizationNotFoundError{GUID: "some-org-guid"})) 80 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 81 }) 82 }) 83 84 When("client returns an error", func() { 85 var expectedErr error 86 87 BeforeEach(func() { 88 expectedErr = errors.New("some get org error") 89 fakeCloudControllerClient.GetOrganizationReturns( 90 ccv2.Organization{}, 91 ccv2.Warnings{"warning-1", "warning-2"}, 92 expectedErr, 93 ) 94 }) 95 96 It("returns warnings and the error", func() { 97 Expect(err).To(MatchError(expectedErr)) 98 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 99 }) 100 }) 101 }) 102 103 Describe("GetOrganizationByName", func() { 104 var ( 105 org Organization 106 warnings Warnings 107 err error 108 ) 109 110 JustBeforeEach(func() { 111 org, warnings, err = actor.GetOrganizationByName("some-org") 112 }) 113 114 When("the org exists", func() { 115 BeforeEach(func() { 116 fakeCloudControllerClient.GetOrganizationsReturns( 117 []ccv2.Organization{ 118 {GUID: "some-org-guid"}, 119 }, 120 ccv2.Warnings{"warning-1", "warning-2"}, 121 nil) 122 }) 123 124 It("returns the org and all warnings", func() { 125 Expect(org.GUID).To(Equal("some-org-guid")) 126 Expect(err).ToNot(HaveOccurred()) 127 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 128 129 Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) 130 filters := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) 131 Expect(filters).To(Equal( 132 []ccv2.Filter{{ 133 Type: constant.NameFilter, 134 Operator: constant.EqualOperator, 135 Values: []string{"some-org"}, 136 }})) 137 }) 138 }) 139 140 When("the org does not exist", func() { 141 BeforeEach(func() { 142 fakeCloudControllerClient.GetOrganizationsReturns( 143 []ccv2.Organization{}, 144 nil, 145 nil, 146 ) 147 }) 148 149 It("returns OrganizationNotFoundError", func() { 150 Expect(err).To(MatchError(actionerror.OrganizationNotFoundError{Name: "some-org"})) 151 }) 152 }) 153 154 When("multiple orgs exist with the same name", func() { 155 BeforeEach(func() { 156 fakeCloudControllerClient.GetOrganizationsReturns( 157 []ccv2.Organization{ 158 {GUID: "org-1-guid"}, 159 {GUID: "org-2-guid"}, 160 }, 161 nil, 162 nil, 163 ) 164 }) 165 166 It("returns MultipleOrganizationsFoundError", func() { 167 Expect(err).To(MatchError("Organization name 'some-org' matches multiple GUIDs: org-1-guid, org-2-guid")) 168 }) 169 }) 170 171 When("an error is encountered", func() { 172 var returnedErr error 173 174 BeforeEach(func() { 175 returnedErr = errors.New("get-orgs-error") 176 fakeCloudControllerClient.GetOrganizationsReturns( 177 []ccv2.Organization{}, 178 ccv2.Warnings{ 179 "warning-1", 180 "warning-2", 181 }, 182 returnedErr, 183 ) 184 }) 185 186 It("returns the error and all warnings", func() { 187 Expect(err).To(MatchError(returnedErr)) 188 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 189 }) 190 }) 191 }) 192 193 Describe("GrantOrgManagerByUsername", func() { 194 var ( 195 guid string 196 username string 197 warnings Warnings 198 err error 199 ) 200 201 JustBeforeEach(func() { 202 warnings, err = actor.GrantOrgManagerByUsername(guid, username) 203 }) 204 205 When("acting as a user", func() { 206 When("making the user an org manager succeeds", func() { 207 BeforeEach(func() { 208 guid = "some-guid" 209 username = "some-user" 210 211 fakeCloudControllerClient.UpdateOrganizationManagerByUsernameReturns( 212 ccv2.Warnings{"warning-1", "warning-2"}, 213 nil, 214 ) 215 }) 216 217 It("returns warnings", func() { 218 Expect(err).ToNot(HaveOccurred()) 219 Expect(fakeCloudControllerClient.UpdateOrganizationManagerByUsernameCallCount()).To(Equal(1)) 220 orgGuid, user := fakeCloudControllerClient.UpdateOrganizationManagerByUsernameArgsForCall(0) 221 Expect(orgGuid).To(Equal("some-guid")) 222 Expect(user).To(Equal("some-user")) 223 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 224 }) 225 }) 226 227 When("making the user an org manager fails", func() { 228 BeforeEach(func() { 229 fakeCloudControllerClient.UpdateOrganizationManagerByUsernameReturns( 230 ccv2.Warnings{"warning-1", "warning-2"}, 231 errors.New("some-error"), 232 ) 233 }) 234 235 It("returns the error and all warnings", func() { 236 Expect(err).To(HaveOccurred()) 237 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 238 Expect(err).To(MatchError("some-error")) 239 }) 240 }) 241 }) 242 243 When("acting as a client", func() { 244 BeforeEach(func() { 245 fakeConfig.UAAGrantTypeReturns(string(uaaconst.GrantTypeClientCredentials)) 246 }) 247 248 When("making the client an org manager succeeds", func() { 249 BeforeEach(func() { 250 guid = "some-guid" 251 username = "some-client-id" 252 253 fakeCloudControllerClient.UpdateOrganizationManagerReturns( 254 ccv2.Warnings{"warning-1", "warning-2"}, 255 nil, 256 ) 257 }) 258 259 It("returns warnings", func() { 260 Expect(err).ToNot(HaveOccurred()) 261 Expect(fakeCloudControllerClient.UpdateOrganizationManagerCallCount()).To(Equal(1)) 262 orgGuid, user := fakeCloudControllerClient.UpdateOrganizationManagerArgsForCall(0) 263 Expect(orgGuid).To(Equal("some-guid")) 264 Expect(user).To(Equal("some-client-id")) 265 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 266 }) 267 }) 268 269 When("making the client an org manager fails", func() { 270 BeforeEach(func() { 271 fakeCloudControllerClient.UpdateOrganizationManagerReturns( 272 ccv2.Warnings{"warning-1", "warning-2"}, 273 errors.New("some-error"), 274 ) 275 }) 276 277 It("returns the error and all warnings", func() { 278 Expect(err).To(HaveOccurred()) 279 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 280 Expect(err).To(MatchError("some-error")) 281 }) 282 }) 283 }) 284 }) 285 286 Describe("CreateOrganization", func() { 287 var ( 288 quotaName string 289 290 org Organization 291 warnings Warnings 292 executeErr error 293 ) 294 295 JustBeforeEach(func() { 296 org, warnings, executeErr = actor.CreateOrganization("some-org", quotaName) 297 }) 298 299 When("a quota is not specified", func() { 300 BeforeEach(func() { 301 quotaName = "" 302 }) 303 304 When("the organization is created successfully", func() { 305 BeforeEach(func() { 306 fakeCloudControllerClient.CreateOrganizationReturns( 307 ccv2.Organization{ 308 GUID: "some-org-guid", 309 Name: "some-org", 310 }, 311 ccv2.Warnings{"warning-1", "warning-2"}, 312 nil) 313 }) 314 315 It("returns the org and all warnings", func() { 316 Expect(executeErr).ToNot(HaveOccurred()) 317 318 Expect(org.GUID).To(Equal("some-org-guid")) 319 Expect(org.Name).To(Equal("some-org")) 320 321 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 322 Expect(fakeCloudControllerClient.GetOrganizationQuotasCallCount()).To(Equal(0)) 323 Expect(fakeCloudControllerClient.CreateOrganizationCallCount()).To(Equal(1)) 324 orgName, quotaGUID := fakeCloudControllerClient.CreateOrganizationArgsForCall(0) 325 Expect(quotaGUID).To(BeEmpty()) 326 Expect(orgName).To(Equal("some-org")) 327 }) 328 }) 329 330 When("creating the organzation fails", func() { 331 BeforeEach(func() { 332 fakeCloudControllerClient.CreateOrganizationReturns( 333 ccv2.Organization{}, 334 ccv2.Warnings{"warning-1", "warning-2"}, 335 errors.New("couldn't make it")) 336 }) 337 338 It("returns the error and warnings", func() { 339 Expect(executeErr).To(MatchError("couldn't make it")) 340 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 341 342 Expect(fakeCloudControllerClient.CreateOrganizationCallCount()).To(Equal(1)) 343 }) 344 345 When("the organization name already exists", func() { 346 BeforeEach(func() { 347 fakeCloudControllerClient.CreateOrganizationReturns( 348 ccv2.Organization{}, 349 ccv2.Warnings{"warning-1", "warning-2"}, 350 ccerror.OrganizationNameTakenError{}, 351 ) 352 }) 353 354 It("wraps the error in an action error", func() { 355 Expect(executeErr).To(MatchError(actionerror.OrganizationNameTakenError{Name: "some-org"})) 356 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 357 Expect(fakeCloudControllerClient.CreateOrganizationCallCount()).To(Equal(1)) 358 }) 359 }) 360 }) 361 }) 362 363 When("a quota name is specified", func() { 364 BeforeEach(func() { 365 quotaName = "some-quota" 366 }) 367 368 When("the fetching the quota succeeds", func() { 369 BeforeEach(func() { 370 fakeCloudControllerClient.GetOrganizationQuotasReturns( 371 []ccv2.OrganizationQuota{ 372 { 373 GUID: "some-quota-definition-guid", 374 Name: "some-quota", 375 }, 376 }, 377 ccv2.Warnings{"quota-warning-1", "quota-warning-2"}, 378 nil) 379 }) 380 381 When("creating the org succeeds", func() { 382 BeforeEach(func() { 383 fakeCloudControllerClient.CreateOrganizationReturns( 384 ccv2.Organization{ 385 GUID: "some-org-guid", 386 Name: "some-org", 387 QuotaDefinitionGUID: "some-quota-definition-guid", 388 }, 389 ccv2.Warnings{"warning-1", "warning-2"}, 390 nil) 391 }) 392 393 It("includes that quota's guid when creating the org", func() { 394 Expect(executeErr).ToNot(HaveOccurred()) 395 Expect(warnings).To(ConsistOf("quota-warning-1", "quota-warning-2", "warning-1", "warning-2")) 396 Expect(org).To(MatchFields(IgnoreExtras, Fields{ 397 "GUID": Equal("some-org-guid"), 398 "Name": Equal("some-org"), 399 "QuotaDefinitionGUID": Equal("some-quota-definition-guid"), 400 })) 401 402 Expect(fakeCloudControllerClient.CreateOrganizationCallCount()).To(Equal(1)) 403 orgName, quotaGUID := fakeCloudControllerClient.CreateOrganizationArgsForCall(0) 404 Expect(quotaGUID).To(Equal("some-quota-definition-guid")) 405 Expect(orgName).To(Equal("some-org")) 406 }) 407 }) 408 409 When("creating the org fails", func() { 410 BeforeEach(func() { 411 fakeCloudControllerClient.CreateOrganizationReturns( 412 ccv2.Organization{}, 413 ccv2.Warnings{"warning-1", "warning-2"}, 414 errors.New("couldn't make it")) 415 }) 416 417 It("returns the error and warnings", func() { 418 Expect(executeErr).To(MatchError("couldn't make it")) 419 Expect(warnings).To(ConsistOf("quota-warning-1", "quota-warning-2", "warning-1", "warning-2")) 420 421 Expect(fakeCloudControllerClient.CreateOrganizationCallCount()).To(Equal(1)) 422 }) 423 }) 424 }) 425 426 When("fetching the quota fails", func() { 427 BeforeEach(func() { 428 fakeCloudControllerClient.GetOrganizationQuotasReturns( 429 nil, 430 ccv2.Warnings{"quota-warning-1", "quota-warning-2"}, 431 errors.New("no quota found")) 432 }) 433 434 It("returns warnings and the error, and does not try to create the org", func() { 435 Expect(executeErr).To(MatchError("no quota found")) 436 Expect(warnings).To(ConsistOf("quota-warning-1", "quota-warning-2")) 437 438 Expect(fakeCloudControllerClient.GetOrganizationQuotasCallCount()).To(Equal(1)) 439 Expect(fakeCloudControllerClient.CreateOrganizationCallCount()).To(Equal(0)) 440 }) 441 }) 442 }) 443 }) 444 445 Describe("DeleteOrganization", func() { 446 var ( 447 warnings Warnings 448 deleteOrgErr error 449 job ccv2.Job 450 ) 451 452 JustBeforeEach(func() { 453 warnings, deleteOrgErr = actor.DeleteOrganization("some-org") 454 }) 455 456 Context("the organization is deleted successfully", func() { 457 BeforeEach(func() { 458 fakeCloudControllerClient.GetOrganizationsReturns([]ccv2.Organization{ 459 {GUID: "some-org-guid"}, 460 }, ccv2.Warnings{"get-org-warning"}, nil) 461 462 job = ccv2.Job{ 463 GUID: "some-job-guid", 464 Status: constant.JobStatusFinished, 465 } 466 467 fakeCloudControllerClient.DeleteOrganizationJobReturns( 468 job, ccv2.Warnings{"delete-org-warning"}, nil) 469 470 fakeCloudControllerClient.PollJobReturns(ccv2.Warnings{"polling-warnings"}, nil) 471 }) 472 473 It("returns warnings and deletes the org", func() { 474 Expect(warnings).To(ConsistOf("get-org-warning", "delete-org-warning", "polling-warnings")) 475 Expect(deleteOrgErr).ToNot(HaveOccurred()) 476 477 Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) 478 filters := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) 479 Expect(filters).To(Equal( 480 []ccv2.Filter{{ 481 Type: constant.NameFilter, 482 Operator: constant.EqualOperator, 483 Values: []string{"some-org"}, 484 }})) 485 486 Expect(fakeCloudControllerClient.DeleteOrganizationJobCallCount()).To(Equal(1)) 487 orgGuid := fakeCloudControllerClient.DeleteOrganizationJobArgsForCall(0) 488 Expect(orgGuid).To(Equal("some-org-guid")) 489 490 Expect(fakeCloudControllerClient.PollJobCallCount()).To(Equal(1)) 491 job := fakeCloudControllerClient.PollJobArgsForCall(0) 492 Expect(job.GUID).To(Equal("some-job-guid")) 493 }) 494 }) 495 496 When("getting the org returns an error", func() { 497 BeforeEach(func() { 498 fakeCloudControllerClient.GetOrganizationsReturns( 499 []ccv2.Organization{}, 500 ccv2.Warnings{ 501 "get-org-warning", 502 }, 503 nil, 504 ) 505 }) 506 507 It("returns an error and all warnings", func() { 508 Expect(warnings).To(ConsistOf("get-org-warning")) 509 Expect(deleteOrgErr).To(MatchError(actionerror.OrganizationNotFoundError{ 510 Name: "some-org", 511 })) 512 }) 513 }) 514 515 When("the delete returns an error", func() { 516 var returnedErr error 517 518 BeforeEach(func() { 519 returnedErr = errors.New("delete-org-error") 520 521 fakeCloudControllerClient.GetOrganizationsReturns( 522 []ccv2.Organization{{GUID: "org-1-guid"}}, 523 ccv2.Warnings{ 524 "get-org-warning", 525 }, 526 nil, 527 ) 528 529 fakeCloudControllerClient.DeleteOrganizationJobReturns( 530 ccv2.Job{}, 531 ccv2.Warnings{"delete-org-warning"}, 532 returnedErr) 533 }) 534 535 It("returns the error and all warnings", func() { 536 Expect(deleteOrgErr).To(MatchError(returnedErr)) 537 Expect(warnings).To(ConsistOf("get-org-warning", "delete-org-warning")) 538 }) 539 }) 540 541 When("the job polling has an error", func() { 542 var expectedErr error 543 BeforeEach(func() { 544 fakeCloudControllerClient.GetOrganizationsReturns([]ccv2.Organization{ 545 {GUID: "some-org-guid"}, 546 }, ccv2.Warnings{"get-org-warning"}, nil) 547 548 fakeCloudControllerClient.DeleteOrganizationJobReturns( 549 ccv2.Job{}, ccv2.Warnings{"delete-org-warning"}, nil) 550 551 expectedErr = errors.New("Never expected, by anyone") 552 fakeCloudControllerClient.PollJobReturns(ccv2.Warnings{"polling-warnings"}, expectedErr) 553 }) 554 555 It("returns the error from job polling", func() { 556 Expect(warnings).To(ConsistOf("get-org-warning", "delete-org-warning", "polling-warnings")) 557 Expect(deleteOrgErr).To(MatchError(expectedErr)) 558 }) 559 }) 560 }) 561 562 Describe("GetOrganizations", func() { 563 var ( 564 orgs []Organization 565 warnings Warnings 566 err error 567 ) 568 569 JustBeforeEach(func() { 570 orgs, warnings, err = actor.GetOrganizations() 571 }) 572 573 When("there are multiple organizations", func() { 574 BeforeEach(func() { 575 fakeCloudControllerClient.GetOrganizationsReturns( 576 []ccv2.Organization{ 577 { 578 Name: "some-org-1", 579 }, 580 { 581 Name: "some-org-2", 582 }, 583 }, 584 ccv2.Warnings{"warning-1", "warning-2"}, 585 nil) 586 }) 587 588 It("returns the org and all warnings", func() { 589 Expect(err).ToNot(HaveOccurred()) 590 591 Expect(orgs).To(HaveLen(2)) 592 Expect(orgs[0].Name).To(Equal("some-org-1")) 593 Expect(orgs[1].Name).To(Equal("some-org-2")) 594 595 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 596 597 Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) 598 queriesArg := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) 599 Expect(queriesArg).To(BeNil()) 600 }) 601 }) 602 603 When("there are no orgs", func() { 604 BeforeEach(func() { 605 fakeCloudControllerClient.GetOrganizationsReturns( 606 []ccv2.Organization{}, 607 ccv2.Warnings{"warning-1", "warning-2"}, 608 nil, 609 ) 610 }) 611 612 It("returns warnings and an empty list of orgs", func() { 613 Expect(err).ToNot(HaveOccurred()) 614 615 Expect(orgs).To(HaveLen(0)) 616 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 617 }) 618 }) 619 620 When("client returns an error", func() { 621 var expectedErr error 622 623 BeforeEach(func() { 624 expectedErr = errors.New("some get org error") 625 fakeCloudControllerClient.GetOrganizationsReturns( 626 []ccv2.Organization{}, 627 ccv2.Warnings{"warning-1", "warning-2"}, 628 expectedErr, 629 ) 630 }) 631 632 It("returns warnings and the error", func() { 633 Expect(err).To(MatchError(expectedErr)) 634 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 635 }) 636 }) 637 }) 638 639 Describe("OrganizationExistsWithName", func() { 640 var ( 641 exists bool 642 warnings Warnings 643 err error 644 ) 645 646 JustBeforeEach(func() { 647 exists, warnings, err = actor.OrganizationExistsWithName("some-org") 648 }) 649 650 When("the org exists", func() { 651 BeforeEach(func() { 652 fakeCloudControllerClient.GetOrganizationsReturns( 653 []ccv2.Organization{ 654 {GUID: "some-org-guid"}, 655 }, 656 ccv2.Warnings{"warning-1", "warning-2"}, 657 nil) 658 }) 659 660 It("succeeds, returning true and warnings", func() { 661 Expect(exists).To(BeTrue()) 662 Expect(err).NotTo(HaveOccurred()) 663 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 664 665 Expect(fakeCloudControllerClient.GetOrganizationsCallCount()).To(Equal(1)) 666 filters := fakeCloudControllerClient.GetOrganizationsArgsForCall(0) 667 Expect(filters).To(Equal( 668 []ccv2.Filter{{ 669 Type: constant.NameFilter, 670 Operator: constant.EqualOperator, 671 Values: []string{"some-org"}, 672 }})) 673 }) 674 }) 675 676 When("the org does not exist", func() { 677 BeforeEach(func() { 678 fakeCloudControllerClient.GetOrganizationsReturns( 679 []ccv2.Organization{}, 680 ccv2.Warnings{"warning-1", "warning-2"}, 681 nil, 682 ) 683 }) 684 685 It("returns false and warnings", func() { 686 Expect(exists).To(BeFalse()) 687 Expect(err).NotTo(HaveOccurred()) 688 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 689 }) 690 }) 691 692 When("fetching organizations throw an error", func() { 693 BeforeEach(func() { 694 fakeCloudControllerClient.GetOrganizationsReturns( 695 []ccv2.Organization{}, 696 ccv2.Warnings{"warning-1", "warning-2"}, 697 errors.New("boom"), 698 ) 699 }) 700 701 It("propagates the error and warnings", func() { 702 Expect(err).To(MatchError("boom")) 703 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 704 }) 705 }) 706 }) 707 })