本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/coreconfig.ReadWriter.SetAPIEndpoint方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadWriter.SetAPIEndpoint方法的具体用法?Golang ReadWriter.SetAPIEndpoint怎么用?Golang ReadWriter.SetAPIEndpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration/coreconfig.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetAPIEndpoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
request, apiErr = ccGateway.NewRequestForFile("PUT", "https://example.com/v2/apps", "BEARER my-access-token", f)
Expect(apiErr).NotTo(HaveOccurred())
})
It("Uses a ProgressReader as the SeekableBody", func() {
Expect(reflect.TypeOf(request.SeekableBody).String()).To(ContainSubstring("ProgressReader"))
})
})
})
Describe("PerformRequestForJSONResponse()", func() {
BeforeEach(func() {
ccServer = ghttp.NewServer()
config.SetAPIEndpoint(ccServer.URL())
})
AfterEach(func() {
ccServer.Close()
})
Context("When CC response with an api error", func() {
BeforeEach(func() {
ccServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/v2/some-endpoint"),
ghttp.VerifyHeader(http.Header{
"accept": []string{"application/json"},
}),
ghttp.RespondWith(http.StatusUnauthorized, `{
示例2:
repo SecurityGroupsRepo
)
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewSecurityGroupsRepo(configRepo, gateway)
})
AfterEach(func() {
testServer.Close()
})
setupTestServer := func(reqs ...testnet.TestRequest) {
testServer, testHandler = testnet.NewServer(reqs)
configRepo.SetAPIEndpoint(testServer.URL)
}
Describe("BindToStagingSet", func() {
It("makes a correct request", func() {
setupTestServer(
apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "PUT",
Path: "/v2/config/staging_security_groups/a-real-guid",
Response: testnet.TestResponse{
Status: http.StatusCreated,
Body: bindStagingResponse,
},
}),
)
示例3:
repo BuildpackRepository
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway(config, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewCloudControllerBuildpackRepository(config, gateway)
})
AfterEach(func() {
ts.Close()
})
var setupTestServer = func(requests ...testnet.TestRequest) {
ts, handler = testnet.NewServer(requests)
config.SetAPIEndpoint(ts.URL)
}
It("lists buildpacks", func() {
setupTestServer(
apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/buildpacks",
Response: testnet.TestResponse{
Status: http.StatusOK,
Body: `{
"next_url": "/v2/buildpacks?page=2",
"resources": [
{
"metadata": {
"guid": "buildpack1-guid"
示例4:
Expect(output).ToNot(ContainSubstrings([]string{"API endpoint:"}))
Expect(output).To(ContainSubstrings([]string{"Not logged in", "Use", "log in"}))
})
})
Context("when an api endpoint is set and the user logged in", func() {
var config coreconfig.ReadWriter
BeforeEach(func() {
accessToken := coreconfig.TokenInfo{
UserGUID: "my-user-guid",
Username: "my-user",
Email: "my-user-email",
}
config = testconfig.NewRepositoryWithAccessToken(accessToken)
config.SetAPIEndpoint("https://test.example.org")
config.SetAPIVersion("☃☃☃")
})
Describe("tells the user what is set in the config", func() {
var output []string
JustBeforeEach(func() {
output = io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger)
ui.ShowConfiguration(config)
})
})
It("tells the user which api endpoint is set", func() {
Expect(output).To(ContainSubstrings([]string{"API endpoint:", "https://test.example.org"}))
示例5:
Expect(err).NotTo(HaveOccurred())
Expect(config.AuthorizationEndpoint).To(Equal("https://login.example.com"))
Expect(config.LoggregatorEndpoint).To(Equal("wss://loggregator.foo.example.org:4443"))
Expect(endpoint).To(Equal(testServer.URL))
Expect(config.SSHOAuthClient).To(Equal("ssh-client-id"))
Expect(config.APIVersion).To(Equal("42.0.0"))
Expect(config.MinCLIVersion).To(Equal("6.5.0"))
Expect(config.MinRecommendedCLIVersion).To(Equal("6.7.0"))
Expect(config.RoutingAPIEndpoint).To(Equal("http://api.example.com/routing"))
})
})
Context("when the API request fails", func() {
BeforeEach(func() {
coreConfig.SetAPIEndpoint("example.com")
})
It("returns a failure response when the server has a bad certificate", func() {
testServer.TLS.Certificates = []tls.Certificate{testnet.MakeExpiredTLSCert()}
_, _, apiErr := repo.GetCCInfo(testServer.URL)
Expect(apiErr).NotTo(BeNil())
})
It("returns a failure response when the API request fails", func() {
testServerFn = func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}
_, _, apiErr := repo.GetCCInfo(testServer.URL)
示例6:
config.SetAPIVersion("2.2.0")
})
JustBeforeEach(func() {
strategy := strategy.NewEndpointStrategy(config.APIVersion())
gateway := net.NewCloudControllerGateway(config, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter))
repo = NewCloudControllerAppEventsRepository(config, gateway, strategy)
})
AfterEach(func() {
server.Close()
})
setupTestServer := func(requests ...testnet.TestRequest) {
server, handler = testnet.NewServer(requests)
config.SetAPIEndpoint(server.URL)
}
Describe("list recent events", func() {
It("returns the most recent events", func() {
setupTestServer(eventsRequest)
list, err := repo.RecentEvents("my-app-guid", 2)
Expect(err).ToNot(HaveOccurred())
timestamp, err := time.Parse(eventTimestampFormat, "2014-01-21T00:20:11+00:00")
Expect(err).ToNot(HaveOccurred())
Expect(list).To(ConsistOf([]models.EventFields{
{
GUID: "event-1-guid",
Name: "audit.app.update",
示例7:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)
var _ = Describe("ServiceBindingsRepository", func() {
var (
server *ghttp.Server
configRepo coreconfig.ReadWriter
repo CloudControllerServiceBindingRepository
)
BeforeEach(func() {
server = ghttp.NewServer()
configRepo = testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(server.URL())
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewCloudControllerServiceBindingRepository(configRepo, gateway)
})
AfterEach(func() {
server.Close()
})
Describe("Create", func() {
var requestBody string
Context("when the service binding can be created", func() {
JustBeforeEach(func() {
server.AppendHandlers(
ghttp.CombineHandlers(