本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/fakes.FakeUserRepository.UnsetOrgRoleByGuidArgsForCall方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeUserRepository.UnsetOrgRoleByGuidArgsForCall方法的具體用法?Golang FakeUserRepository.UnsetOrgRoleByGuidArgsForCall怎麽用?Golang FakeUserRepository.UnsetOrgRoleByGuidArgsForCall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/api/fakes.FakeUserRepository
的用法示例。
在下文中一共展示了FakeUserRepository.UnsetOrgRoleByGuidArgsForCall方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
userFields := models.UserFields{Guid: "the-user-guid", Username: "the-user-name"}
userRequirement.GetUserReturns(userFields)
})
It("tells the user it is removing the role", func() {
cmd.Execute(flagContext)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Removing role", "OrgManager", "the-user-name", "the-org", "the-user-name"},
[]string{"OK"},
))
})
It("removes the role using the GUID", func() {
cmd.Execute(flagContext)
Expect(userRepo.UnsetOrgRoleByGuidCallCount()).To(Equal(1))
actualUserGUID, actualOrgGUID, actualRole := userRepo.UnsetOrgRoleByGuidArgsForCall(0)
Expect(actualUserGUID).To(Equal("the-user-guid"))
Expect(actualOrgGUID).To(Equal("the-org-guid"))
Expect(actualRole).To(Equal("OrgManager"))
})
Context("when the call to CC fails", func() {
BeforeEach(func() {
userRepo.UnsetOrgRoleByGuidReturns(errors.New("user-repo-error"))
})
It("panics and prints a failure message", func() {
Expect(func() { cmd.Execute(flagContext) }).To(Panic())
Expect(ui.Outputs).To(BeInDisplayOrder(
[]string{"FAILED"},
[]string{"user-repo-error"},
示例2:
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"},
))
userGUID, orgGUID, role := userRepo.UnsetOrgRoleByGuidArgsForCall(0)
Expect(userGUID).To(Equal("some-user-guid"))
Expect(role).To(Equal(models.ORG_MANAGER))
Expect(orgGUID).To(Equal("some-org-guid"))
})
})
})