github.com/jasonkeene/cli@v6.14.1-0.20160816203908-ca5715166dfb+incompatible/cf/requirements/routing_api_test.go (about) 1 package requirements_test 2 3 import ( 4 "github.com/cloudfoundry/cli/cf/configuration/coreconfig" 5 "github.com/cloudfoundry/cli/cf/requirements" 6 7 testconfig "github.com/cloudfoundry/cli/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 })