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


Golang FakeReqFactory.UserFields方法代码示例

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


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

示例1:

			Expect(requirementsFactory.OrganizationName).To(Equal("org"))
		})
	})

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

			user := models.UserFields{}
			user.Username = "some-user"
			user.Guid = "some-user-guid"
			org := models.Organization{}
			org.Name = "some-org"
			org.Guid = "some-org-guid"

			requirementsFactory.UserFields = user
			requirementsFactory.Organization = org
		})

		It("unsets a user's org role", func() {
			runCommand("my-username", "my-org", "OrgManager")

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Removing role", "OrgManager", "my-username", "my-org", "my-user"},
				[]string{"OK"},
			))

			Expect(userRepo.UnsetOrgRoleRole).To(Equal(models.ORG_MANAGER))
			Expect(userRepo.UnsetOrgRoleUserGuid).To(Equal("some-user-guid"))
			Expect(userRepo.UnsetOrgRoleOrganizationGuid).To(Equal("some-org-guid"))
		})
开发者ID:hail100,项目名称:cli,代码行数:31,代码来源:unset_org_role_test.go

示例2:

			})
		})

		Context("when the space is found", func() {
			BeforeEach(func() {
				space := models.Space{}
				space.Guid = "the-space-guid"
				space.Name = "the-space-name"
				space.Organization = org.OrganizationFields
				spaceRepo.FindByNameInOrgReturns(space, nil)
			})

			Context("when the UserRequirement returns a user with a GUID", func() {
				BeforeEach(func() {
					userFields := models.UserFields{Guid: "the-user-guid", Username: "the-username"}
					requirementsFactory.UserFields = userFields
				})

				It("tells the user it is assigning the role", func() {
					cmd.Execute(flagContext)
					Expect(ui.Outputs).To(ContainSubstrings(
						[]string{"Assigning role", "SpaceManager", "the-username", "the-org", "the-username"},
						[]string{"OK"},
					))
				})

				It("sets the role using the GUID", func() {
					cmd.Execute(flagContext)
					Expect(userRepo.SetSpaceRoleByGuidCallCount()).To(Equal(1))
					actualUserGUID, actualSpaceGUID, actualOrgGUID, actualRole := userRepo.SetSpaceRoleByGuidArgsForCall(0)
					Expect(actualUserGUID).To(Equal("the-user-guid"))
开发者ID:evanfarrar,项目名称:cli,代码行数:31,代码来源:set_space_role_test.go

示例3:

		})

		It("fails with usage when not provided exactly three args", func() {
			runCommand("one fish", "two fish") // red fish, blue fish
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

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

			org := models.Organization{}
			org.Guid = "my-org-guid"
			org.Name = "my-org"
			requirementsFactory.UserFields = models.UserFields{Guid: "my-user-guid", Username: "my-user"}
			requirementsFactory.Organization = org
		})

		It("sets the given org role on the given user", func() {
			runCommand("some-user", "some-org", "OrgManager")

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Assigning role", "OrgManager", "my-user", "my-org", "my-user"},
				[]string{"OK"},
			))
			Expect(userRepo.SetOrgRoleUserGuid).To(Equal("my-user-guid"))
			Expect(userRepo.SetOrgRoleOrganizationGuid).To(Equal("my-org-guid"))
			Expect(userRepo.SetOrgRoleRole).To(Equal(models.ORG_MANAGER))
		})
	})
开发者ID:hail100,项目名称:cli,代码行数:31,代码来源:set_org_role_test.go


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