本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/commandregistry.Dependency.Config方法的典型用法代码示例。如果您正苦于以下问题:Golang Dependency.Config方法的具体用法?Golang Dependency.Config怎么用?Golang Dependency.Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/commandregistry.Dependency
的用法示例。
在下文中一共展示了Dependency.Config方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
)
var _ = Describe("routes command", func() {
var (
ui *testterm.FakeUI
routeRepo *apifakes.FakeRouteRepository
domainRepo *apifakes.FakeDomainRepository
configRepo coreconfig.Repository
requirementsFactory *requirementsfakes.FakeFactory
deps commandregistry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.RepoLocator = deps.RepoLocator.SetRouteRepository(routeRepo).SetDomainRepository(domainRepo)
deps.Config = configRepo
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("routes").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
routeRepo = new(apifakes.FakeRouteRepository)
domainRepo = new(apifakes.FakeDomainRepository)
})
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("routes", args, requirementsFactory, updateCommandDependency, false, ui)
示例2:
ui *testterm.FakeUI
authRepo *authenticationfakes.FakeAuthenticationRepository
endpointRepo *coreconfigfakes.FakeEndpointRepository
orgRepo *organizationsfakes.FakeOrganizationRepository
spaceRepo *apifakes.FakeSpaceRepository
org models.Organization
deps commandregistry.Dependency
minCLIVersion string
minRecommendedCLIVersion string
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = Config
deps.RepoLocator = deps.RepoLocator.SetEndpointRepository(endpointRepo)
deps.RepoLocator = deps.RepoLocator.SetAuthenticationRepository(authRepo)
deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo)
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("login").SetDependency(deps, pluginCall))
}
listSpacesStub := func(spaces []models.Space) func(func(models.Space) bool) error {
return func(cb func(models.Space) bool) error {
var keepGoing bool
for _, s := range spaces {
keepGoing = cb(s)
if !keepGoing {
return nil
}
示例3:
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
application = models.Application{}
application.Name = "my-app"
application.GUID = "my-app-guid"
application.InstanceCount = 1
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(application)
requirementsFactory.NewApplicationRequirementReturns(applicationReq)
})
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = config
deps.RepoLocator = deps.RepoLocator.SetAppInstancesRepository(appInstancesRepo)
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("restart-app-instance").SetDependency(deps, pluginCall))
}
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("restart-app-instance", args, requirementsFactory, updateCommandDependency, false, ui)
}
Describe("requirements", func() {
It("fails if not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(runCommand("my-app", "0")).To(BeFalse())
})
It("fails if a space is not targeted", func() {
示例4:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("password command", func() {
var (
pwDeps passwordDeps
ui *testterm.FakeUI
deps commandregistry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = pwDeps.Config
deps.RepoLocator = deps.RepoLocator.SetPasswordRepository(pwDeps.PwdRepo)
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("passwd").SetDependency(deps, pluginCall))
}
callPassword := func(inputs []string, pwDeps passwordDeps) (*testterm.FakeUI, bool) {
ui = &testterm.FakeUI{Inputs: inputs}
passed := testcmd.RunCLICommand("passwd", []string{}, pwDeps.ReqFactory, updateCommandDependency, false, ui)
return ui, passed
}
BeforeEach(func() {
pwDeps = getPasswordDeps()
})
It("does not pass requirements if you are not logged in", func() {