github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/cf/requirements/routing_api_test.go (about) 1 package requirements_test 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 5 "code.cloudfoundry.org/cli/cf/requirements" 6 7 testconfig "code.cloudfoundry.org/cli/util/testhelpers/configuration" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("RoutingApi", func() { 14 var ( 15 config coreconfig.Repository 16 requirement requirements.RoutingAPIRequirement 17 ) 18 19 BeforeEach(func() { 20 config = testconfig.NewRepositoryWithAccessToken(coreconfig.TokenInfo{Username: "my-user"}) 21 requirement = requirements.NewRoutingAPIRequirement(config) 22 }) 23 24 Context("when the config has a zero-length RoutingAPIEndpoint", func() { 25 BeforeEach(func() { 26 config.SetRoutingAPIEndpoint("") 27 }) 28 29 It("errors", func() { 30 err := requirement.Execute() 31 Expect(err.Error()).To(ContainSubstring("This command requires the Routing API. Your targeted endpoint reports it is not enabled.")) 32 }) 33 }) 34 35 Context("when the config has a RoutingAPIEndpoint", func() { 36 BeforeEach(func() { 37 config.SetRoutingAPIEndpoint("api.example.com") 38 }) 39 40 It("does not error", func() { 41 err := requirement.Execute() 42 Expect(err).NotTo(HaveOccurred()) 43 }) 44 }) 45 })