github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/command/v6/shared/new_networking_client_test.go (about)

     1  package shared_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/command/commandfakes"
     5  	. "code.cloudfoundry.org/cli/command/v6/shared"
     6  	"code.cloudfoundry.org/cli/util/ui"
     7  
     8  	"code.cloudfoundry.org/cli/api/uaa"
     9  
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  	. "github.com/onsi/gomega/gbytes"
    13  )
    14  
    15  var _ = Describe("New Clients", func() {
    16  	var (
    17  		binaryName    string
    18  		fakeConfig    *commandfakes.FakeConfig
    19  		testUI        *ui.UI
    20  		fakeUAAClient *uaa.Client
    21  	)
    22  
    23  	BeforeEach(func() {
    24  		binaryName = "faceman"
    25  		fakeConfig = new(commandfakes.FakeConfig)
    26  		fakeConfig.BinaryNameReturns(binaryName)
    27  
    28  		testUI = ui.NewTestUI(NewBuffer(), NewBuffer(), NewBuffer())
    29  	})
    30  
    31  	It("returns a networking client", func() {
    32  		client, err := NewNetworkingClient("some-url", fakeConfig, fakeUAAClient, testUI)
    33  		Expect(err).NotTo(HaveOccurred())
    34  		Expect(client).NotTo(BeNil())
    35  	})
    36  
    37  	When("the network policy api endpoint is not set", func() {
    38  		It("returns an error", func() {
    39  			_, err := NewNetworkingClient("", fakeConfig, fakeUAAClient, testUI)
    40  			Expect(err).To(MatchError("This command requires Network Policy API V1. Your targeted endpoint does not expose it."))
    41  		})
    42  	})
    43  })