github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+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 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("LogCacheURL", func() { 14 var ( 15 actor *Actor 16 fakeCloudControllerClient *v3actionfakes.FakeCloudControllerClient 17 fakeConfig *v3actionfakes.FakeConfig 18 actualLogCacheURL string 19 ) 20 21 JustBeforeEach(func() { 22 actualLogCacheURL = actor.LogCacheURL() 23 }) 24 25 BeforeEach(func() { 26 actor, fakeCloudControllerClient, fakeConfig, _, _ = NewTestActor() 27 fakeConfig.TargetReturns("https://api.the-best-domain.com") 28 }) 29 30 When("fakeCloudControllerClient.GetInfo() succeeds", func() { 31 When("there is a log cache url", func() { 32 var configuredLogcacheURL string 33 BeforeEach(func() { 34 configuredLogcacheURL = "https://log-cache.up-to-date-logging.com" 35 fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ 36 Links: ccv3.InfoLinks{ 37 LogCache: ccv3.APILink{ 38 HREF: configuredLogcacheURL, 39 }}}, ccv3.ResourceLinks{}, ccv3.Warnings{}, nil) 40 }) 41 It("uses it", func() { 42 Expect(actualLogCacheURL).To(Equal(configuredLogcacheURL)) 43 }) 44 }) 45 46 When("there is no log cache url", func() { 47 BeforeEach(func() { 48 fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ 49 Links: ccv3.InfoLinks{}, 50 }, ccv3.ResourceLinks{}, ccv3.Warnings{}, nil) 51 }) 52 It("uses the target", func() { 53 Expect(actualLogCacheURL).To(Equal("https://log-cache.the-best-domain.com")) 54 }) 55 }) 56 }) 57 58 When("fakeCloudControllerClient.GetInfo() fails", func() { 59 BeforeEach(func() { 60 fakeCloudControllerClient.GetInfoReturns(ccv3.Info{ 61 Links: ccv3.InfoLinks{}, 62 }, ccv3.ResourceLinks{}, ccv3.Warnings{}, errors.New("awf splatz!")) 63 }) 64 It("uses the target", func() { 65 Expect(actualLogCacheURL).To(Equal("https://log-cache.the-best-domain.com")) 66 }) 67 }) 68 })