當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeOrganizationRepository.FindByNameReturns方法代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/api/organizations/organizationsfakes.FakeOrganizationRepository.FindByNameReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeOrganizationRepository.FindByNameReturns方法的具體用法?Golang FakeOrganizationRepository.FindByNameReturns怎麽用?Golang FakeOrganizationRepository.FindByNameReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/cloudfoundry/org/cli/cf/api/organizations/organizationsfakes.FakeOrganizationRepository的用法示例。


在下文中一共展示了FakeOrganizationRepository.FindByNameReturns方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

							runCommand("-s", "space-name", "source-app", "target-app")
							Expect(ui.Outputs()).To(ContainSubstrings(
								[]string{"FAILED"},
								[]string{"Error finding space by name."},
							))
						})
					})
				})

				Describe("when an org and space name are passed as parameters", func() {
					It("send the correct target application for the space and org", func() {
						orgRepo.FindByNameReturns(models.Organization{
							Spaces: []models.SpaceFields{
								{
									Name: "space-name",
									GUID: "space-guid",
								},
							},
						}, nil)

						runCommand("-o", "org-name", "-s", "space-name", "source-app", "target-app")

						targetAppName, spaceGUID := appRepo.ReadFromSpaceArgsForCall(0)
						Expect(targetAppName).To(Equal("target-app"))
						Expect(spaceGUID).To(Equal("space-guid"))

						sourceAppGUID, targetAppGUID := copyAppSourceRepo.CopyApplicationArgsForCall(0)
						Expect(sourceAppGUID).To(Equal("source-app-guid"))
						Expect(targetAppGUID).To(Equal("target-app-guid"))

						appArg, orgName, spaceName := appRestarter.ApplicationRestartArgsForCall(0)
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:copy_source_test.go

示例2:

var _ = Describe("OrganizationRequirement", func() {
	var orgRepo *organizationsfakes.FakeOrganizationRepository
	BeforeEach(func() {
		orgRepo = new(organizationsfakes.FakeOrganizationRepository)
	})

	Context("when an org with the given name exists", func() {
		It("succeeds", func() {
			org := models.Organization{}
			org.Name = "my-org-name"
			org.GUID = "my-org-guid"
			orgReq := NewOrganizationRequirement("my-org-name", orgRepo)

			orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
			orgRepo.FindByNameReturns(org, nil)

			err := orgReq.Execute()
			Expect(err).NotTo(HaveOccurred())
			Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-org-name"))
			Expect(orgReq.GetOrganization()).To(Equal(org))
		})
	})

	It("fails when the org with the given name does not exist", func() {
		orgError := errors.New("not found")
		orgRepo.FindByNameReturns(models.Organization{}, orgError)

		err := NewOrganizationRequirement("foo", orgRepo).Execute()
		Expect(err).To(HaveOccurred())
		Expect(err).To(Equal(orgError))
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:organization_test.go

示例3:

		))

		Expect(spaceRepo.CreateCallCount()).To(Equal(1))
		actualSpaceName, _, _ := spaceRepo.CreateArgsForCall(0)
		Expect(actualSpaceName).To(Equal("my-space"))
		Expect(userRepo.SetSpaceRoleByGUIDCallCount()).To(BeZero())
	})

	Context("when the -o flag is provided", func() {
		It("creates a space within that org", func() {
			org := models.Organization{
				OrganizationFields: models.OrganizationFields{
					Name: "other-org",
					GUID: "org-guid-1",
				}}
			orgRepo.FindByNameReturns(org, nil)

			runCommand("-o", "other-org", "my-space")

			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Creating space", "my-space", "other-org", "my-user"},
				[]string{"OK"},
				[]string{"Assigning", "my-user", "my-space", "SpaceManager"},
				[]string{"Assigning", "my-user", "my-space", "SpaceDeveloper"},
				[]string{"TIP"},
			))

			actualSpaceName, actualOrgGUID, _ := spaceRepo.CreateArgsForCall(0)
			Expect(actualSpaceName).To(Equal("my-space"))
			Expect(actualOrgGUID).To(Equal(org.GUID))
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:create_space_test.go

示例4:

		var expectOrgToBeCleared = func() {
			Expect(config.OrganizationFields()).To(Equal(models.OrganizationFields{}))
		}

		var expectSpaceToBeCleared = func() {
			Expect(config.SpaceFields()).To(Equal(models.SpaceFields{}))
		}

		Context("there are no errors", func() {
			BeforeEach(func() {
				org := models.Organization{}
				org.Name = "my-organization"
				org.GUID = "my-organization-guid"

				orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
				orgRepo.FindByNameReturns(org, nil)
				config.SetOrganizationFields(models.OrganizationFields{Name: org.Name, GUID: org.GUID})
			})

			It("it updates the organization in the config", func() {
				callTarget([]string{"-o", "my-organization"})

				Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
				Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
				Expect(ui.ShowConfigurationCalled).To(BeTrue())

				Expect(config.OrganizationFields().GUID).To(Equal("my-organization-guid"))
			})

			It("updates the space in the config", func() {
				space := models.Space{}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:target_test.go

示例5:

	}

	BeforeEach(func() {
		ui = &testterm.FakeUI{
			Inputs: []string{"y"},
		}
		config = testconfig.NewRepositoryWithDefaults()
		requirementsFactory = new(requirementsfakes.FakeFactory)

		org = models.Organization{}
		org.Name = "org-to-delete"
		org.GUID = "org-to-delete-guid"
		orgRepo = new(organizationsfakes.FakeOrganizationRepository)

		orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
		orgRepo.FindByNameReturns(org, nil)
	})

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

	It("fails requirements when not logged in", func() {
		requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
		Expect(runCommand("some-org-name")).To(BeFalse())
	})

	It("fails with usage if no arguments are given", func() {
		runCommand()
		Expect(ui.Outputs()).To(ContainSubstrings(
			[]string{"Incorrect Usage", "Requires an argument"},
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:delete_org_test.go

示例6:

			})

			It("fails and tells the user", func() {
				runCommand("my-nonexistent-security-group", "my-org", "my-space")

				Expect(fakeSecurityGroupRepo.ReadArgsForCall(0)).To(Equal("my-nonexistent-security-group"))
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"security group", "my-nonexistent-security-group", "not found"},
				))
			})
		})

		Context("when the org does not exist", func() {
			BeforeEach(func() {
				fakeOrgRepo.FindByNameReturns(models.Organization{}, errors.New("Org org not found"))
			})

			It("fails and tells the user", func() {
				runCommand("sec group", "org", "space")

				Expect(fakeOrgRepo.FindByNameArgsForCall(0)).To(Equal("org"))
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"Org", "org", "not found"},
				))
			})
		})

		Context("when the space does not exist", func() {
			BeforeEach(func() {
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:bind_security_group_test.go

示例7:

				[]string{"Creating org", "my-org"},
				[]string{"OK"},
				[]string{"my-org", "already exists"},
			))
		})

		Context("when CC api version supports assigning orgRole by name, and feature-flag 'set_roles_by_username' is enabled", func() {
			BeforeEach(func() {
				config.SetAPIVersion("2.37.0")
				flagRepo.FindByNameReturns(models.FeatureFlag{
					Name:    "set_roles_by_username",
					Enabled: true,
				}, nil)
				orgRepo.FindByNameReturns(models.Organization{
					OrganizationFields: models.OrganizationFields{
						GUID: "my-org-guid",
					},
				}, nil)
			})

			It("assigns manager role to user", func() {
				runCommand("my-org")

				orgGUID, role, userGUID, userName := orgRoleSetter.SetOrgRoleArgsForCall(0)

				Expect(orgRoleSetter.SetOrgRoleCallCount()).To(Equal(1))
				Expect(orgGUID).To(Equal("my-org-guid"))
				Expect(role).To(Equal(models.RoleOrgManager))
				Expect(userGUID).To(Equal(""))
				Expect(userName).To(Equal("my-user"))
			})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:create_org_test.go

示例8:

				returnedBroker := serviceBroker1
				brokerBuilder.GetBrokerWithSpecifiedServiceReturns(returnedBroker, nil)

				brokers, err := actor.FilterBrokers("", "my-service1", "")
				Expect(err).NotTo(HaveOccurred())

				Expect(len(brokers)).To(Equal(1))
				Expect(len(brokers[0].Services)).To(Equal(1))

				Expect(brokers[0].Services[0].GUID).To(Equal("service-guid1"))
			})
		})

		Context("when the -o flag is passed", func() {
			It("returns an error if the org does not actually exist", func() {
				orgRepo.FindByNameReturns(models.Organization{}, errors.NewModelNotFoundError("organization", "org-that-shall-not-be-found"))
				_, err := actor.FilterBrokers("", "", "org-that-shall-not-be-found")

				Expect(err).To(HaveOccurred())
			})

			It("returns a slice of brokers containing Services/Service Plans visible to the org", func() {
				serviceBroker1.Services = []models.ServiceOffering{service1}
				returnedBroker := []models.ServiceBroker{serviceBroker1}

				serviceBuilder.GetServicesVisibleToOrgReturns([]models.ServiceOffering{service1}, nil)
				brokerBuilder.AttachBrokersToServicesReturns(returnedBroker, nil)

				brokers, err := actor.FilterBrokers("", "", "org1")
				Expect(err).NotTo(HaveOccurred())
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:services_test.go

示例9:

		deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo)
		commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("delete-space-quota").SetDependency(deps, pluginCall))
	}

	BeforeEach(func() {
		ui = &testterm.FakeUI{}
		quotaRepo = new(spacequotasfakes.FakeSpaceQuotaRepository)
		orgRepo = new(organizationsfakes.FakeOrganizationRepository)
		configRepo = testconfig.NewRepositoryWithDefaults()
		requirementsFactory = new(requirementsfakes.FakeFactory)

		org := models.Organization{}
		org.Name = "my-org"
		org.GUID = "my-org-guid"
		orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
		orgRepo.FindByNameReturns(org, nil)
	})

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

	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")).To(BeFalse())
		})
	})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:delete_space_quota_test.go

示例10:

				space2.GUID = "some-space-guid"
				space2.Name = "some-space"

				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"))
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:login_test.go

示例11:

		servicePlanVisibilityRepo = new(apifakes.FakeServicePlanVisibilityRepository)
		orgRepo = new(organizationsfakes.FakeOrganizationRepository)
		planBuilder = new(planbuilderfakes.FakePlanBuilder)
		serviceBuilder = new(servicebuilderfakes.FakeServiceBuilder)

		actor = actors.NewServicePlanHandler(servicePlanRepo, servicePlanVisibilityRepo, orgRepo, planBuilder, serviceBuilder)

		org1 = models.Organization{}
		org1.Name = "org-1"
		org1.GUID = "org-1-guid"

		org2 = models.Organization{}
		org2.Name = "org-2"
		org2.GUID = "org-2-guid"

		orgRepo.FindByNameReturns(org1, nil)

		publicServicePlanVisibilityFields = models.ServicePlanVisibilityFields{
			GUID:            "public-service-plan-visibility-guid",
			ServicePlanGUID: "public-service-plan-guid",
		}

		privateServicePlanVisibilityFields = models.ServicePlanVisibilityFields{
			GUID:            "private-service-plan-visibility-guid",
			ServicePlanGUID: "private-service-plan-guid",
		}

		limitedServicePlanVisibilityFields = models.ServicePlanVisibilityFields{
			GUID:             "limited-service-plan-visibility-guid",
			ServicePlanGUID:  "limited-service-plan-guid",
			OrganizationGUID: "org-1-guid",
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:services_plans_test.go


注:本文中的code/cloudfoundry/org/cli/cf/api/organizations/organizationsfakes.FakeOrganizationRepository.FindByNameReturns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。