本文整理匯總了Golang中testhelpers/api.FakeOrgRepository.FindByNameErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeOrgRepository.FindByNameErr方法的具體用法?Golang FakeOrgRepository.FindByNameErr怎麽用?Golang FakeOrgRepository.FindByNameErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類testhelpers/api.FakeOrgRepository
的用法示例。
在下文中一共展示了FakeOrgRepository.FindByNameErr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
defaultOrgRepo.FindByNameNotFound = true
ui := callCreateSpace([]string{"-o", "cool-organization", "my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"cool-organization", "does not exist"},
})
Expect(defaultSpaceRepo.CreateSpaceName).To(Equal(""))
})
It("TestCreateSpaceInOrgWhenErrorFindingOrg", func() {
resetSpaceDefaults()
defaultOrgRepo.FindByNameErr = true
ui := callCreateSpace([]string{"-o", "cool-organization", "my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"error"},
})
Expect(defaultSpaceRepo.CreateSpaceName).To(Equal(""))
})
It("TestCreateSpaceWhenItAlreadyExists", func() {
resetSpaceDefaults()
defaultSpaceRepo.CreateSpaceExists = true
ui := callCreateSpace([]string{"my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo)
示例2:
orgRepo.Organizations = []models.Organization{org}
orgRepo.FindByNameOrganization = org
ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo)
Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
})
It("TestTargetOrganizationWhenUserDoesNotHaveAccess", func() {
orgs := []models.Organization{}
orgRepo.Organizations = orgs
orgRepo.FindByNameErr = true
ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{{"FAILED"}})
})
It("TestTargetOrganizationWhenOrgNotFound", func() {
orgRepo.FindByNameNotFound = true
ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"my-organization", "not found"},
})
})