本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeFactory.NewMinAPIVersionRequirementReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFactory.NewMinAPIVersionRequirementReturns方法的具體用法?Golang FakeFactory.NewMinAPIVersionRequirementReturns怎麽用?Golang FakeFactory.NewMinAPIVersionRequirementReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeFactory
的用法示例。
在下文中一共展示了FakeFactory.NewMinAPIVersionRequirementReturns方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
})
Context("when the user is not logged in", func() {
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
})
It("fails requirements", func() {
Expect(runCommand("my-quota", "-m", "50G")).To(BeFalse())
})
})
Context("when the user is logged in", func() {
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewMinAPIVersionRequirementReturns(requirements.Passing{})
})
It("fails requirements when called without a quota name", func() {
runCommand()
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
It("creates a quota with a given name", func() {
runCommand("my-quota")
Expect(quotaRepo.CreateArgsForCall(0).Name).To(Equal("my-quota"))
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Creating quota", "my-quota", "my-user", "..."},
[]string{"OK"},
示例2:
deps.UI = ui
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.Config = config
deps.PlanBuilder = planBuilder
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("update-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
requirementsFactory.NewMinAPIVersionRequirementReturns(requirements.Passing{Type: "minAPIVersionReq"})
serviceRepo = new(apifakes.FakeServiceRepository)
planBuilder = new(planbuilderfakes.FakePlanBuilder)
offering1 = models.ServiceOffering{}
offering1.Label = "cleardb"
offering1.Plans = []models.ServicePlanFields{{
Name: "spark",
GUID: "cleardb-spark-guid",
}, {
Name: "flare",
GUID: "cleardb-flare-guid",
},
}
示例3:
RepoLocator: repoLocator,
}
reqFactory = new(requirementsfakes.FakeFactory)
loginReq = new(requirementsfakes.FakeRequirement)
loginReq.ExecuteReturns(nil)
reqFactory.NewLoginRequirementReturns(loginReq)
targetedOrgReq = new(requirementsfakes.FakeTargetedOrgRequirement)
targetedOrgReq.ExecuteReturns(nil)
reqFactory.NewTargetedOrgRequirementReturns(targetedOrgReq)
minApiVersionReq = new(requirementsfakes.FakeRequirement)
minApiVersionReq.ExecuteReturns(nil)
reqFactory.NewMinAPIVersionRequirementReturns(minApiVersionReq)
cmd = spacequota.CreateSpaceQuota{}
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
})
Describe("Requirements", func() {
BeforeEach(func() {
cmd.SetDependency(deps, false)
})
Context("when not exactly one arg is provided", func() {
It("fails", func() {
flagContext.Parse()
_, err := cmd.Requirements(reqFactory, flagContext)
Expect(err).To(HaveOccurred())
Expect(ui.Outputs()).To(ContainSubstrings(
示例4:
ui = new(testterm.FakeUI)
routingAPIRepo = new(apifakes.FakeRoutingAPIRepository)
config = testconfig.NewRepositoryWithDefaults()
repoLocator = api.RepositoryLocator{}.SetRoutingAPIRepository(routingAPIRepo)
deps = commandregistry.Dependency{
UI: ui,
Config: config,
RepoLocator: repoLocator,
}
minAPIVersionRequirement = new(requirementsfakes.FakeRequirement)
loginRequirement = new(requirementsfakes.FakeRequirement)
routingAPIEndpoingRequirement = new(requirementsfakes.FakeRequirement)
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewMinAPIVersionRequirementReturns(minAPIVersionRequirement)
requirementsFactory.NewLoginRequirementReturns(loginRequirement)
requirementsFactory.NewRoutingAPIRequirementReturns(routingAPIEndpoingRequirement)
cmd = new(routergroups.RouterGroups)
cmd = cmd.SetDependency(deps, false).(*routergroups.RouterGroups)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
})
Describe("Requirements", func() {
It("fails if the user is not logged in", func() {
cmd.Requirements(requirementsFactory, flagContext)
Expect(requirementsFactory.NewLoginRequirementCallCount()).To(Equal(1))
})
示例5:
It("fails with usage if space quota name is not provided", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
runCommand()
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
Context("the minimum API version requirement", func() {
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
requirementsFactory.NewMinAPIVersionRequirementReturns(requirements.Failing{Message: "not min api"})
})
It("fails when the -a option is provided", func() {
Expect(runCommand("my-quota", "-a", "10")).To(BeFalse())
Expect(requirementsFactory.NewMinAPIVersionRequirementCallCount()).To(Equal(1))
option, version := requirementsFactory.NewMinAPIVersionRequirementArgsForCall(0)
Expect(option).To(Equal("Option '-a'"))
Expect(version).To(Equal(cf.SpaceAppInstanceLimitMinimumAPIVersion))
})
It("does not fail when the -a option is not provided", func() {
Expect(runCommand("my-quota", "-m", "10G")).To(BeTrue())
})
})
})