github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/requirements/api_endpoint_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 testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("APIEndpointRequirement", func() { 12 var ( 13 config coreconfig.Repository 14 ) 15 16 BeforeEach(func() { 17 config = testconfig.NewRepository() 18 }) 19 20 It("succeeds when given a config with an API endpoint", func() { 21 config.SetAPIEndpoint("api.example.com") 22 req := NewAPIEndpointRequirement(config) 23 err := req.Execute() 24 Expect(err).NotTo(HaveOccurred()) 25 }) 26 27 It("fails when given a config without an API endpoint", func() { 28 req := NewAPIEndpointRequirement(config) 29 err := req.Execute() 30 Expect(err).To(HaveOccurred()) 31 32 Expect(err.Error()).To(ContainSubstring("No API endpoint set")) 33 }) 34 })