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


Golang FakeReqFactory.LoginSuccess方法代码示例

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


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

示例1: init

func init() {
	Describe("migrating service instances from v1 to v2", func() {
		var (
			ui                  *testterm.FakeUI
			serviceRepo         *testapi.FakeServiceRepo
			cmd                 *MigrateServiceInstances
			requirementsFactory *testreq.FakeReqFactory
			context             *cli.Context
			args                []string
		)

		BeforeEach(func() {
			ui = &testterm.FakeUI{}
			config := testconfig.NewRepository()
			serviceRepo = &testapi.FakeServiceRepo{}
			cmd = NewMigrateServiceInstances(ui, config, serviceRepo)
			requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: false}
			args = []string{}
		})

		Describe("requirements", func() {
			It("requires you to be logged in", func() {
				context = testcmd.NewContext("migrate-service-instances", args)
				testcmd.RunCommand(cmd, context, requirementsFactory)

				Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
			})

			It("requires five arguments to run", func() {
				requirementsFactory.LoginSuccess = true
				args = []string{"one", "two", "three"}
				context = testcmd.NewContext("migrate-service-instances", args)
				testcmd.RunCommand(cmd, context, requirementsFactory)

				Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
			})

			It("passes requirements if user is logged in and provided five args to run", func() {
				requirementsFactory.LoginSuccess = true
				args = []string{"one", "two", "three", "four", "five"}
				ui.Inputs = append(ui.Inputs, "no")

				context = testcmd.NewContext("migrate-service-instances", args)
				testcmd.RunCommand(cmd, context, requirementsFactory)

				Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
			})
		})

		Describe("migrating service instances", func() {
			BeforeEach(func() {
				requirementsFactory.LoginSuccess = true
				args = []string{"v1-service-name", "v1-provider-name", "v1-plan-name", "v2-service-name", "v2-plan-name"}
				context = testcmd.NewContext("migrate-service-instances", args)
				serviceRepo.ServiceInstanceCountForServicePlan = 1
			})

			It("displays the warning and the prompt including info about the instances and plan to migrate", func() {
				ui.Inputs = []string{""}
				testcmd.RunCommand(cmd, context, requirementsFactory)

				testassert.SliceContains(ui.Outputs, testassert.Lines{
					{"WARNING:", "this operation is to replace a service broker"},
				})
				testassert.SliceContains(ui.Prompts, testassert.Lines{
					{"Really migrate", "1 service instance",
						"from plan", "v1-service-name", "v1-provider-name", "v1-plan-name",
						"to", "v2-service-name", "v2-plan-name"},
				})
			})

			Context("when the user confirms", func() {
				BeforeEach(func() {
					ui.Inputs = []string{"yes"}
				})

				Context("when the v1 and v2 service instances exists", func() {
					BeforeEach(func() {
						serviceRepo.FindServicePlanByDescriptionResultGuids = []string{"v1-guid", "v2-guid"}
						serviceRepo.MigrateServicePlanFromV1ToV2ReturnedCount = 1
					})

					It("makes a request to migrate the v1 service instance", func() {
						testcmd.RunCommand(cmd, context, requirementsFactory)

						Expect(serviceRepo.V1GuidToMigrate).To(Equal("v1-guid"))
						Expect(serviceRepo.V2GuidToMigrate).To(Equal("v2-guid"))
					})

					It("finds the v1 service plan by its name, provider and service label", func() {
						testcmd.RunCommand(cmd, context, requirementsFactory)

						expectedV1 := api.ServicePlanDescription{
							ServicePlanName: "v1-plan-name",
							ServiceProvider: "v1-provider-name",
							ServiceName:     "v1-service-name",
						}
						Expect(serviceRepo.FindServicePlanByDescriptionArguments[0]).To(Equal(expectedV1))
					})

//.........这里部分代码省略.........
开发者ID:normalnorman,项目名称:cli,代码行数:101,代码来源:migrate_service_instances_test.go

示例2:

	It("fails with usage when provided too many or two few args", func() {
		runCommand("org")
		Expect(ui.FailedWithUsage).To(BeTrue())

		runCommand("org", "quota", "extra-stuff")
		Expect(ui.FailedWithUsage).To(BeTrue())
	})

	It("fails requirements when not logged in", func() {
		runCommand("my-org", "my-quota")
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
	})

	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
		})

		It("passes requirements when provided two args", func() {
			runCommand("my-org", "my-quota")
			Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
			Expect(requirementsFactory.OrganizationName).To(Equal("my-org"))
		})

		It("assigns a quota to an org", func() {
			org := models.Organization{}
			org.Name = "my-org"
			org.Guid = "my-org-guid"

			quota := models.QuotaFields{Name: "my-quota", Guid: "my-quota-guid"}
开发者ID:nota-ja,项目名称:cli,代码行数:30,代码来源:set_quota_test.go

示例3:

		repo                *testapi.FakeBuildpackRepository
		bitsRepo            *testapi.FakeBuildpackBitsRepository
		ui                  *testterm.FakeUI
		cmd                 CreateBuildpack
	)

	BeforeEach(func() {
		requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
		repo = &testapi.FakeBuildpackRepository{}
		bitsRepo = &testapi.FakeBuildpackBitsRepository{}
		ui = &testterm.FakeUI{}
		cmd = NewCreateBuildpack(ui, repo, bitsRepo)
	})

	It("fails requirements when the user is not logged in", func() {
		requirementsFactory.LoginSuccess = false
		context := testcmd.NewContext("create-buildpack", []string{"my-buildpack", "my-dir", "0"})
		testcmd.RunCommand(cmd, context, requirementsFactory)

		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
	})

	It("fails with usage when given fewer than three arguments", func() {
		context := testcmd.NewContext("create-buildpack", []string{})
		testcmd.RunCommand(cmd, context, requirementsFactory)

		Expect(ui.FailedWithUsage).To(BeTrue())
	})

	It("creates and uploads buildpacks", func() {
		context := testcmd.NewContext("create-buildpack", []string{"my-buildpack", "my.war", "5"})
开发者ID:nota-ja,项目名称:cli,代码行数:31,代码来源:create_buildpack_test.go

示例4:

	BeforeEach(func() {
		ui = new(testterm.FakeUI)
		configRepo = testconfig.NewRepositoryWithDefaults()
		reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
		spaceRepo = &testapi.FakeSpaceRepository{}
	})

	var callRenameSpace = func(args []string) {
		cmd := NewRenameSpace(ui, configRepo, spaceRepo)
		testcmd.RunCommand(cmd, testcmd.NewContext("create-space", args), reqFactory)
	}

	Describe("when the user is not logged in", func() {
		It("does not pass requirements", func() {
			reqFactory.LoginSuccess = false
			callRenameSpace([]string{"my-space", "my-new-space"})
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Describe("when the user has not targeted an org", func() {
		It("does not pass requirements", func() {
			reqFactory.TargetedOrgSuccess = false
			callRenameSpace([]string{"my-space", "my-new-space"})
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Describe("when the user provides fewer than two args", func() {
		It("fails with usage", func() {
开发者ID:knolleary,项目名称:cli,代码行数:30,代码来源:rename_space_test.go

示例5:

	})

	It("fails requirements when not logged in", func() {
		callRenameOrg([]string{"my-org", "my-new-org"}, reqFactory, orgRepo)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
	})

	Context("when logged in and given an org to rename", func() {
		var ui *testterm.FakeUI

		BeforeEach(func() {
			org := models.Organization{}
			org.Name = "my-org"
			org.Guid = "my-org-guid"
			reqFactory.Organization = org
			reqFactory.LoginSuccess = true
			ui = callRenameOrg([]string{"my-org", "my-new-org"}, reqFactory, orgRepo)
		})

		It("pass requirements", func() {
			Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
		})

		It("renames an organization", func() {
			Expect(reqFactory.OrganizationName).To(Equal("my-org"))
			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"Renaming org", "my-org", "my-new-org", "my-user"},
				{"OK"},
			})

			Expect(orgRepo.RenameOrganizationGuid).To(Equal("my-org-guid"))
开发者ID:normalnorman,项目名称:cli,代码行数:31,代码来源:rename_org_test.go

示例6:

	)

	BeforeEach(func() {
		reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
		restarter = &testcmd.FakeAppRestarter{}
		appRepo = &testapi.FakeApplicationRepository{}
		ui = new(testterm.FakeUI)
		configRepo = testconfig.NewRepositoryWithDefaults()
		cmd = NewScale(ui, configRepo, restarter, appRepo)
	})

	Describe("requirements", func() {
		It("requires the user to be logged in with a targed space", func() {
			args := []string{"-m", "1G", "my-app"}

			reqFactory.LoginSuccess = false
			reqFactory.TargetedSpaceSuccess = true

			testcmd.RunCommand(cmd, testcmd.NewContext("scale", args), reqFactory)
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

			reqFactory.LoginSuccess = true
			reqFactory.TargetedSpaceSuccess = false

			testcmd.RunCommand(cmd, testcmd.NewContext("scale", args), reqFactory)
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})

		It("requires an app to be specified", func() {
			testcmd.RunCommand(cmd, testcmd.NewContext("scale", []string{"-m", "1G"}), reqFactory)
开发者ID:knolleary,项目名称:cli,代码行数:30,代码来源:scale_test.go


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