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


Golang FakeUI.Inputs方法代码示例

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


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

示例1:

	})

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

	Describe("requirements", func() {
		It("fails with usage when not provided a path to the plugin executable", func() {
			Expect(runCommand()).ToNot(HavePassedRequirements())
		})
	})

	Context("when the -f flag is not provided", func() {
		Context("and the user responds with 'y'", func() {
			It("continues to install the plugin", func() {
				ui.Inputs = []string{"y"}
				runCommand("pluggy", "-r", "somerepo")
				Expect(ui.Outputs()).To(ContainSubstrings([]string{"Looking up 'pluggy' from repository 'somerepo'"}))
			})
		})

		Context("but the user responds with 'n'", func() {
			It("quits with a message", func() {
				ui.Inputs = []string{"n"}
				runCommand("pluggy", "-r", "somerepo")
				Expect(ui.Outputs()).To(ContainSubstrings([]string{"Plugin installation cancelled"}))
			})
		})
	})

	Describe("Locating binary file", func() {
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:install_plugin_test.go

示例2:

		})

		It("deletes the service auth token", func() {
			runCommand("a label", "a provider")
			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Deleting service auth token as", "my-user"},
				[]string{"OK"},
			))

			Expect(authTokenRepo.FindByLabelAndProviderLabel).To(Equal("a label"))
			Expect(authTokenRepo.FindByLabelAndProviderProvider).To(Equal("a provider"))
			Expect(authTokenRepo.DeletedServiceAuthTokenFields.GUID).To(Equal("the-guid"))
		})

		It("does nothing when the user does not confirm", func() {
			ui.Inputs = []string{"nope"}
			runCommand("a label", "a provider")

			Expect(ui.Prompts).To(ContainSubstrings(
				[]string{"Really delete", "service auth token", "a label", "a provider"},
			))
			Expect(ui.Outputs()).To(BeEmpty())
			Expect(authTokenRepo.DeletedServiceAuthTokenFields).To(Equal(models.ServiceAuthTokenFields{}))
		})

		It("does not prompt the user when the -f flag is given", func() {
			ui.Inputs = []string{}
			runCommand("-f", "a label", "a provider")

			Expect(ui.Prompts).To(BeEmpty())
			Expect(ui.Outputs()).To(ContainSubstrings(
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:delete_service_auth_token_test.go

示例3:

	Describe("requirements", func() {
		It("requires you to be logged in", func() {
			Expect(testcmd.RunCLICommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false, ui)).To(BeFalse())
		})

		It("requires five arguments to run", func() {
			args = []string{"one", "two", "three"}

			Expect(testcmd.RunCLICommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false, ui)).To(BeFalse())
		})

		It("requires CC API version 2.47 or lower", func() {
			requirementsFactory.NewMaxAPIVersionRequirementReturns(requirements.Failing{Message: "max api version not met"})
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			args = []string{"one", "two", "three", "four", "five"}
			ui.Inputs = append(ui.Inputs, "no")

			Expect(testcmd.RunCLICommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false, ui)).To(BeFalse())
		})

		It("passes requirements if user is logged in and provided five args to run", func() {
			requirementsFactory.NewMaxAPIVersionRequirementReturns(requirements.Passing{})
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			args = []string{"one", "two", "three", "four", "five"}
			ui.Inputs = append(ui.Inputs, "no")
			serviceRepo.GetServiceInstanceCountForServicePlanReturns(1, nil)

			Expect(testcmd.RunCLICommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false, ui)).To(BeTrue())
		})
	})
开发者ID:fujitsu-cf,项目名称:cli,代码行数:30,代码来源:migrate_service_instances_test.go

示例4:

						"port":     "3306",
						"database": "fake-db-name",
						"uri":      "mysql://fake-user:[email protected]:3306/fake-db-name",
					},
				}
			})

			It("deletes service key successfully when '-f' option is provided", func() {
				Expect(callDeleteServiceKey([]string{"fake-service-instance", "fake-service-key", "-f"})).To(BeTrue())
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Deleting key", "fake-service-key", "for service instance", "fake-service-instance", "as", "my-user"},
					[]string{"OK"}))
			})

			It("deletes service key successfully when '-f' option is not provided and confirmed 'yes'", func() {
				ui.Inputs = append(ui.Inputs, "yes")

				Expect(callDeleteServiceKey([]string{"fake-service-instance", "fake-service-key"})).To(BeTrue())
				Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the service key", "fake-service-key"}))
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Deleting key", "fake-service-key", "for service instance", "fake-service-instance", "as", "my-user"},
					[]string{"OK"}))
			})

			It("skips to delete service key when '-f' option is not provided and confirmed 'no'", func() {
				ui.Inputs = append(ui.Inputs, "no")

				Expect(callDeleteServiceKey([]string{"fake-service-instance", "fake-service-key"})).To(BeTrue())
				Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the service key", "fake-service-key"}))
				Expect(ui.Outputs()).To(BeEmpty())
			})
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:delete_service_key_test.go

示例5:

		space = models.Space{SpaceFields: models.SpaceFields{
			Name: "space-to-delete",
			GUID: "space-to-delete-guid",
		}}

		requirementsFactory = new(requirementsfakes.FakeFactory)
		requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
		spaceReq := new(requirementsfakes.FakeSpaceRequirement)
		spaceReq.GetSpaceReturns(space)
		requirementsFactory.NewSpaceRequirementReturns(spaceReq)
	})

	Describe("requirements", func() {
		BeforeEach(func() {
			ui.Inputs = []string{"y"}
		})
		It("fails when not logged in", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})

			Expect(runCommand("my-space")).To(BeFalse())
		})

		It("fails when not targeting a space", func() {
			targetedOrgReq := new(requirementsfakes.FakeTargetedOrgRequirement)
			targetedOrgReq.ExecuteReturns(errors.New("no org targeted"))
			requirementsFactory.NewTargetedOrgRequirementReturns(targetedOrgReq)

			Expect(runCommand("my-space")).To(BeFalse())
		})
	})
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:delete_space_test.go

示例6:

				})

				It("tries to update the user provided service instance with the credentials", func() {
					Expect(runCLIErr).NotTo(HaveOccurred())
					Expect(serviceInstanceRepo.UpdateCallCount()).To(Equal(1))
					serviceInstanceFields := serviceInstanceRepo.UpdateArgsForCall(0)
					Expect(serviceInstanceFields.Params).To(Equal(map[string]interface{}{
						"some": "json",
					}))
				})
			})

			Context("when the -p flag is passed with inline JSON", func() {
				BeforeEach(func() {
					flagContext.Parse("service-instance", "-p", `key1,key2`)
					ui.Inputs = []string{"value1", "value2"}
				})

				It("prompts the user for the values", func() {
					Expect(runCLIErr).NotTo(HaveOccurred())
					Expect(ui.Prompts).To(ContainSubstrings(
						[]string{"key1"},
						[]string{"key2"},
					))
				})

				It("tries to update the user provided service instance with the credentials", func() {
					Expect(runCLIErr).NotTo(HaveOccurred())

					Expect(serviceInstanceRepo.UpdateCallCount()).To(Equal(1))
					serviceInstanceFields := serviceInstanceRepo.UpdateArgsForCall(0)
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:update_user_provided_service_test.go

示例7:

					[]string{"OK"},
				))

				Expect(orgRepo.DeleteArgsForCall(0)).To(Equal("org-to-delete-guid"))
			})

			It("does not untarget the org and space", func() {
				runCommand("org-to-delete")

				Expect(config.OrganizationFields().Name).To(Equal("some-other-org"))
				Expect(config.SpaceFields().Name).To(Equal("some-other-space"))
			})
		})

		It("does not prompt when the -f flag is given", func() {
			ui.Inputs = []string{}
			runCommand("-f", "org-to-delete")

			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Deleting", "org-to-delete"},
				[]string{"OK"},
			))

			Expect(orgRepo.DeleteArgsForCall(0)).To(Equal("org-to-delete-guid"))
		})

		It("warns the user when the org does not exist", func() {
			orgRepo.FindByNameReturns(models.Organization{}, errors.NewModelNotFoundError("Organization", "org org-to-delete does not exist"))

			runCommand("org-to-delete")
开发者ID:fujitsu-cf,项目名称:cli,代码行数:30,代码来源:delete_org_test.go

示例8:

				orgRepo.ListOrgsReturns([]models.Organization{org1, org2}, nil)
				spaceRepo.ListSpacesStub = listSpacesStub([]models.Space{space1, space2})
				spaceRepo.FindByNameStub = func(name string) (models.Space, error) {
					m := map[string]models.Space{
						space1.Name: space1,
						space2.Name: space2,
					}
					return m[name], nil
				}
			})

			It("lets the user select an org and space by number", func() {
				orgRepo.FindByNameReturns(org2, nil)
				OUT_OF_RANGE_CHOICE := "3"
				ui.Inputs = []string{"api.example.com", "[email protected]", "password", OUT_OF_RANGE_CHOICE, "2", OUT_OF_RANGE_CHOICE, "1"}

				testcmd.RunCLICommand("login", Flags, nil, updateCommandDependency, false, ui)

				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Select an org"},
					[]string{"1. some-org"},
					[]string{"2. my-new-org"},
					[]string{"Select a space"},
					[]string{"1. my-space"},
					[]string{"2. some-space"},
				))

				Expect(Config.OrganizationFields().GUID).To(Equal("my-new-org-guid"))
				Expect(Config.SpaceFields().GUID).To(Equal("my-space-guid"))
				Expect(Config.AccessToken()).To(Equal("my_access_token"))
开发者ID:fujitsu-cf,项目名称:cli,代码行数:30,代码来源:login_test.go

示例9:

				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Showing", "my-app", "my-org", "my-space", "my-user"},
					[]string{"OK"},
					[]string{"memory", "256M"},
					[]string{"disk", "1G"},
					[]string{"instances", "42"},
				))

				Expect(ui.Outputs()).ToNot(ContainSubstrings([]string{"Scaling", "my-app", "my-org", "my-space", "my-user"}))
			})
		})

		Context("when the user does not confirm 'yes'", func() {
			It("does not restart the app", func() {
				ui.Inputs = []string{"whatever"}
				testcmd.RunCLICommand("scale", []string{"-i", "5", "-m", "512M", "-k", "2G", "my-app"}, requirementsFactory, updateCommandDependency, false, ui)

				Expect(restarter.ApplicationRestartCallCount()).To(Equal(0))
			})
		})

		Context("when the user provides the -f flag", func() {
			It("does not prompt the user", func() {
				testcmd.RunCLICommand("scale", []string{"-f", "-i", "5", "-m", "512M", "-k", "2G", "my-app"}, requirementsFactory, updateCommandDependency, false, ui)

				application, orgName, spaceName := restarter.ApplicationRestartArgsForCall(0)
				Expect(application).To(Equal(app))
				Expect(orgName).To(Equal(config.OrganizationFields().Name))
				Expect(spaceName).To(Equal(config.SpaceFields().Name))
			})
开发者ID:fujitsu-cf,项目名称:cli,代码行数:30,代码来源:scale_test.go

示例10:

				runCommand("foo.com")

				Expect(domainRepo.DeleteArgsForCall(0)).To(Equal("foo-guid"))

				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Deleting domain", "foo.com"},
					[]string{"FAILED"},
					[]string{"foo.com"},
					[]string{"failed badly"},
				))
			})
		})

		Context("when the user does not confirm", func() {
			BeforeEach(func() {
				ui.Inputs = []string{"no"}
			})

			It("does nothing", func() {
				runCommand("foo.com")

				Expect(domainRepo.DeleteCallCount()).To(BeZero())

				Expect(ui.Prompts).To(ContainSubstrings([]string{"delete", "foo.com"}))

				Expect(ui.Outputs()).To(BeEmpty())
			})
		})

		Context("when the user provides the -f flag", func() {
			BeforeEach(func() {
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:delete_domain_test.go


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