本文整理汇总了Golang中code/cloudfoundry/org/cli/cf/commandregistry.Command.Execute方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Execute方法的具体用法?Golang Command.Execute怎么用?Golang Command.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/cloudfoundry/org/cli/cf/commandregistry.Command
的用法示例。
在下文中一共展示了Command.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Describe("Execute", func() {
var err error
BeforeEach(func() {
flagContext.Parse("the-user-name", "the-org-name", "OrgManager")
cmd.Requirements(factory, flagContext)
org := models.Organization{}
org.GUID = "the-org-guid"
org.Name = "the-org-name"
organizationRequirement.GetOrganizationReturns(org)
})
JustBeforeEach(func() {
err = cmd.Execute(flagContext)
})
Context("when the UserRequirement returns a user with a GUID", func() {
BeforeEach(func() {
userFields := models.UserFields{GUID: "the-user-guid", Username: "the-user-name"}
userRequirement.GetUserReturns(userFields)
})
It("tells the user it is removing the role", func() {
Expect(err).NotTo(HaveOccurred())
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Removing role", "OrgManager", "the-user-name", "the-org", "the-user-name"},
[]string{"OK"},
))
})
示例2:
Expect(actualRequirements).To(ContainElement(minAPIVersionRequirement))
})
})
})
Describe("Execute", func() {
BeforeEach(func() {
err := flagContext.Parse("service-instance-name")
Expect(err).NotTo(HaveOccurred())
cmd.Requirements(factory, flagContext)
})
It("finds the instance by name in the service repo", func() {
err := flagContext.Parse("service-instance-name", "-f")
Expect(err).NotTo(HaveOccurred())
cmd.Execute(flagContext)
Expect(serviceRepo.FindInstanceByNameCallCount()).To(Equal(1))
})
Context("when the instance can be found", func() {
var serviceInstance models.ServiceInstance
BeforeEach(func() {
serviceInstance = models.ServiceInstance{}
serviceInstance.Name = "service-instance-name"
serviceRepo.FindInstanceByNameReturns(serviceInstance, nil)
})
It("warns the user", func() {
ui.Inputs = []string{"n"}
cmd.Execute(flagContext)
示例3:
BeforeEach(func() {
ui = &testterm.FakeUI{}
deps := commandregistry.Dependency{
UI: ui,
}
cmd = &commands.Version{}
cmd.SetDependency(deps, false)
})
Describe("Execute", func() {
var flagContext flags.FlagContext
BeforeEach(func() {
cf.Version = "5.0.0"
cf.Name = "my-special-cf"
cf.BuiltOnDate = "2016-02-29"
})
It("prints the version", func() {
cmd.Execute(flagContext)
Expect(ui.Outputs()).To(Equal([]string{
"my-special-cf version 5.0.0-2016-02-29",
}))
})
})
})
示例4:
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"))
})
Context("when updating the endpoint succeeds", func() {
ccInfo := &coreconfig.CCInfo{
APIVersion: "some-version",
AuthorizationEndpoint: "auth/endpoint",
LoggregatorEndpoint: "loggregator/endpoint",
MinCLIVersion: "min-cli-version",
MinRecommendedCLIVersion: "min-rec-cli-version",