github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+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/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  })