github.com/cloudfoundry/cli@v7.1.0+incompatible/actor/v3action/logcache_test.go (about) 1 package v3action_test 2 3 import ( 4 "errors" 5 6 . "code.cloudfoundry.org/cli/actor/v3action" 7 "code.cloudfoundry.org/cli/actor/v3action/v3actionfakes" 8 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 9 "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("LogCacheURL", func() { 15 var ( 16 actor *Actor 17 fakeCloudControllerClient *v3actionfakes.FakeCloudControllerClient 18 fakeConfig *v3actionfakes.FakeConfig 19 actualLogCacheURL string 20 ) 21 22 JustBeforeEach(func() { 23 actualLogCacheURL = actor.LogCacheURL() 24 }) 25 26 BeforeEach(func() { 27 actor, fakeCloudControllerClient, fakeConfig, _, _ = NewTestActor() 28 fakeConfig.TargetReturns("https://api.the-best-domain.com") 29 }) 30 31 When("fakeCloudControllerClient.GetInfo() succeeds", func() { 32 When("there is a log cache url", func() { 33 var configuredLogcacheURL string 34 BeforeEach(func() { 35 configuredLogcacheURL = "https://log-cache.up-to-date-logging.com" 36 fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ 37 Links: ccv3.InfoLinks{ 38 LogCache: ccv3.APILink{ 39 HREF: configuredLogcacheURL, 40 }}}, ccv3.ResourceLinks{}, ccv3.Warnings{}, nil) 41 }) 42 It("uses it", func() { 43 Expect(actualLogCacheURL).To(Equal(configuredLogcacheURL)) 44 }) 45 }) 46 47 When("there is no log cache url", func() { 48 BeforeEach(func() { 49 fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ 50 Links: ccv3.InfoLinks{}, 51 }, ccv3.ResourceLinks{}, ccv3.Warnings{}, nil) 52 }) 53 It("uses the target", func() { 54 if ccversion.MinSupportedV2ClientVersion != "2.128.0" { 55 Fail("TIMEBOMB: This log-cache behavior should be removed in January 2021 when we no longer support cf-deployment 7.0.0") 56 } 57 Expect(actualLogCacheURL).To(Equal("https://log-cache.the-best-domain.com")) 58 }) 59 }) 60 }) 61 62 When("fakeCloudControllerClient.GetInfo() fails", func() { 63 BeforeEach(func() { 64 fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ 65 Links: ccv3.InfoLinks{}, 66 }, ccv3.ResourceLinks{}, ccv3.Warnings{}, errors.New("awf splatz!")) 67 }) 68 It("uses the target", func() { 69 Expect(actualLogCacheURL).To(Equal("https://log-cache.the-best-domain.com")) 70 }) 71 }) 72 })