github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/actor/v7action/info_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/v7actionfakes" 8 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Info Actions", func() { 14 var ( 15 actor *Actor 16 fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient 17 ) 18 19 BeforeEach(func() { 20 fakeCloudControllerClient = new(v7actionfakes.FakeCloudControllerClient) 21 actor = NewActor(fakeCloudControllerClient, nil, nil, nil, nil, nil) 22 }) 23 24 Describe("GetLogCacheEndpoint", func() { 25 When("getting info is successful", func() { 26 BeforeEach(func() { 27 fakeCloudControllerClient.GetInfoReturns( 28 ccv3.Info{ 29 Links: ccv3.InfoLinks{ 30 LogCache: ccv3.APILink{HREF: "some-log-cache-url"}, 31 }, 32 }, 33 nil, 34 ccv3.Warnings{"warning-1", "warning-2"}, 35 nil, 36 ) 37 }) 38 39 It("returns all warnings and the log cache url", func() { 40 logCacheURL, warnings, err := actor.GetLogCacheEndpoint() 41 Expect(err).ToNot(HaveOccurred()) 42 43 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 44 45 Expect(fakeCloudControllerClient.GetInfoCallCount()).To(Equal(1)) 46 Expect(logCacheURL).To(Equal("some-log-cache-url")) 47 }) 48 }) 49 50 When("the cloud controller client returns an error", func() { 51 var expectedErr error 52 53 BeforeEach(func() { 54 expectedErr = errors.New("I am a CloudControllerClient Error") 55 fakeCloudControllerClient.GetInfoReturns( 56 ccv3.Info{}, 57 nil, 58 ccv3.Warnings{"warning-1", "warning-2"}, 59 expectedErr, 60 ) 61 }) 62 63 It("returns the same error and all warnings", func() { 64 _, warnings, err := actor.GetLogCacheEndpoint() 65 Expect(err).To(MatchError(expectedErr)) 66 Expect(warnings).To(ConsistOf("warning-1", "warning-2")) 67 }) 68 69 }) 70 }) 71 })