当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeFactory.NewTargetedOrgRequirementReturns方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeFactory.NewTargetedOrgRequirementReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeFactory.NewTargetedOrgRequirementReturns方法的具体用法?Golang FakeFactory.NewTargetedOrgRequirementReturns怎么用?Golang FakeFactory.NewTargetedOrgRequirementReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeFactory的用法示例。


在下文中一共展示了FakeFactory.NewTargetedOrgRequirementReturns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

		deps = commandregistry.Dependency{
			UI:          ui,
			Config:      config,
			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() {
开发者ID:jasonkeene,项目名称:cli,代码行数:30,代码来源:create_space_quota_test.go

示例2:

	})

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("space-quotas", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	Describe("requirements", func() {
		It("requires the user to be logged in", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
			Expect(runCommand()).ToNot(HavePassedRequirements())
		})

		It("requires the user to target an org", func() {
			orgReq := new(requirementsfakes.FakeTargetedOrgRequirement)
			orgReq.ExecuteReturns(errors.New("not targeting org"))
			requirementsFactory.NewTargetedOrgRequirementReturns(orgReq)
			Expect(runCommand()).ToNot(HavePassedRequirements())
		})

		Context("when arguments are provided", func() {
			var cmd commandregistry.Command
			var flagContext flags.FlagContext

			BeforeEach(func() {
				cmd = &spacequota.ListSpaceQuotas{}
				cmd.SetDependency(deps, false)
				flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
			})

			It("should fail with usage", func() {
				flagContext.Parse("blahblah")
开发者ID:jasonkeene,项目名称:cli,代码行数:31,代码来源:space_quotas_test.go

示例3:

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("delete-shared-domain", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	Describe("requirements", func() {
		It("fails if you are not logged in", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
			Expect(runCommand("foo.com")).To(BeFalse())
		})

		It("fails if an organiztion is not targeted", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})

			targetedOrganizationReq := new(requirementsfakes.FakeTargetedOrgRequirement)
			targetedOrganizationReq.ExecuteReturns(errors.New("not targeted"))
			requirementsFactory.NewTargetedOrgRequirementReturns(targetedOrganizationReq)

			Expect(runCommand("foo.com")).To(BeFalse())
		})
	})

	Context("when the domain is owned", func() {
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
			domainRepo.FindByNameInOrgReturns(
				models.DomainFields{
					Name:   "foo1.com",
					GUID:   "foo1-guid",
					Shared: false,
				}, nil)
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:delete_shared_domain_test.go

示例4:

		requirementsFactory *requirementsfakes.FakeFactory
		configRepo          *coreconfigfakes.FakeRepository
		deps                commandregistry.Dependency
		cmd                 spacequota.SetSpaceQuota
		flagContext         flags.FlagContext
		loginReq            requirements.Requirement
		orgReq              *requirementsfakes.FakeTargetedOrgRequirement
	)

	BeforeEach(func() {
		requirementsFactory = new(requirementsfakes.FakeFactory)

		loginReq = requirements.Passing{Type: "login"}
		requirementsFactory.NewLoginRequirementReturns(loginReq)
		orgReq = new(requirementsfakes.FakeTargetedOrgRequirement)
		requirementsFactory.NewTargetedOrgRequirementReturns(orgReq)

		ui = new(testterm.FakeUI)
		configRepo = new(coreconfigfakes.FakeRepository)
		deps = commandregistry.Dependency{
			UI:     ui,
			Config: configRepo,
		}
		quotaRepo = new(spacequotasfakes.FakeSpaceQuotaRepository)
		deps.RepoLocator = deps.RepoLocator.SetSpaceQuotaRepository(quotaRepo)
		spaceRepo = new(spacesfakes.FakeSpaceRepository)
		deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)

		flagContext = flags.NewFlagContext(cmd.MetaData().Flags)

		cmd = spacequota.SetSpaceQuota{}
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:set_space_quota_test.go

示例5:

			UI:          ui,
			Config:      configRepo,
			RepoLocator: repoLocator,
		}

		cmd = domain.ListDomains{}
		cmd.SetDependency(deps, false)

		flagContext = flags.NewFlagContext(cmd.MetaData().Flags)

		factory = new(requirementsfakes.FakeFactory)
		loginRequirement = &passingRequirement{Name: "LoginRequirement"}
		factory.NewLoginRequirementReturns(loginRequirement)

		targetedOrgRequirement = new(requirementsfakes.FakeTargetedOrgRequirement)
		factory.NewTargetedOrgRequirementReturns(targetedOrgRequirement)

		domainRepo.ListDomainsForOrgStub = func(orgGUID string, cb func(models.DomainFields) bool) error {
			for _, field := range domainFields {
				if !cb(field) {
					break
				}
			}
			return nil
		}

		routerGroups = models.RouterGroups{
			models.RouterGroup{
				GUID: "router-group-guid",
				Name: "my-router-name1",
				Type: "tcp",
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:domains_test.go


注:本文中的github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeFactory.NewTargetedOrgRequirementReturns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。