本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/coreconfig/coreconfigfakes.FakeEndpointRepository.GetCCInfoReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeEndpointRepository.GetCCInfoReturns方法的具体用法?Golang FakeEndpointRepository.GetCCInfoReturns怎么用?Golang FakeEndpointRepository.GetCCInfoReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration/coreconfig/coreconfigfakes.FakeEndpointRepository
的用法示例。
在下文中一共展示了FakeEndpointRepository.GetCCInfoReturns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
})
ItSucceeds()
ItShowsTheTarget()
It("stores the API endpoint and the skip-ssl flag", func() {
Expect(endpointRepo.GetCCInfoCallCount()).To(Equal(1))
Expect(endpointRepo.GetCCInfoArgsForCall(0)).To(Equal("https://api.the-server.com"))
Expect(Config.IsSSLDisabled()).To(BeTrue())
})
})
Describe("setting api endpoint failed", func() {
BeforeEach(func() {
Config.SetSSLDisabled(true)
endpointRepo.GetCCInfoReturns(nil, "", errors.New("API endpoint not found"))
})
ItFails()
ItDoesntShowTheTarget()
It("clears the entire config", func() {
Expect(Config.APIEndpoint()).To(BeEmpty())
Expect(Config.IsSSLDisabled()).To(BeFalse())
Expect(Config.AccessToken()).To(BeEmpty())
Expect(Config.RefreshToken()).To(BeEmpty())
Expect(Config.OrganizationFields().GUID).To(BeEmpty())
Expect(Config.SpaceFields().GUID).To(BeEmpty())
})
})
})
示例2:
repoLocator = api.RepositoryLocator{}.SetEndpointRepository(endpointRepo)
deps = commandregistry.Dependency{
UI: ui,
Config: config,
RepoLocator: repoLocator,
}
cmd = commands.API{}.SetDependency(deps, false).(commands.API)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
})
Context("when the api endpoint's ssl certificate is invalid", func() {
It("warns the user and prints out a tip", func() {
endpointRepo.GetCCInfoReturns(nil, "", errors.NewInvalidSSLCert("https://buttontomatoes.org", "why? no. go away"))
callApi([]string{"https://buttontomatoes.org"})
Expect(runCLIErr).To(HaveOccurred())
Expect(runCLIErr.Error()).To(ContainSubstring("Invalid SSL Cert for https://buttontomatoes.org"))
Expect(runCLIErr.Error()).To(ContainSubstring("TIP"))
Expect(runCLIErr.Error()).To(ContainSubstring("--skip-ssl-validation"))
})
})
Context("when the user does not provide an endpoint", func() {
Context("when the endpoint is set in the config", func() {
BeforeEach(func() {
config.SetAPIEndpoint("https://api.run.pivotal.io")
config.SetAPIVersion("2.0")
config.SetSSLDisabled(true)
示例3:
Expect(firstErr.Error()).To(ContainSubstring("Incorrect Usage. No argument required"))
})
})
})
Describe("Execute", func() {
var runCLIerr error
BeforeEach(func() {
cmd.Requirements(factory, flagContext)
endpointRepo.GetCCInfoReturns(
&coreconfig.CCInfo{
LoggregatorEndpoint: "loggregator/endpoint",
},
"some-endpoint",
nil,
)
})
JustBeforeEach(func() {
runCLIerr = cmd.Execute(flagContext)
})
It("tries to update the endpoint", func() {
Expect(runCLIerr).NotTo(HaveOccurred())
Expect(endpointRepo.GetCCInfoCallCount()).To(Equal(1))
Expect(endpointRepo.GetCCInfoArgsForCall(0)).To(Equal("fake-api-endpoint"))
})
示例4:
BeforeEach(func() {
ccInfo = &CCInfo{
LoggregatorEndpoint: "some-endpoint",
}
endpointRepo = new(coreconfigfakes.FakeEndpointRepository)
r = APIConfigRefresher{
EndpointRepo: endpointRepo,
Config: new(coreconfigfakes.FakeReadWriter),
Endpoint: "api.some.endpoint.com",
}
})
It("gives a warning", func() {
endpointRepo.GetCCInfoReturns(ccInfo, "api.some.endpoint.com", nil)
warning, err := r.Refresh()
Expect(err).NotTo(HaveOccurred())
Expect(warning.Warn()).To(Equal("Warning: Insecure http API endpoint detected: secure https API endpoints are recommended\n"))
})
})
Context("when the cloud controller returns a secure api endpoint", func() {
var (
r APIConfigRefresher
ccInfo *CCInfo
endpointRepo *coreconfigfakes.FakeEndpointRepository
)
BeforeEach(func() {
ccInfo = &CCInfo{