本文整理匯總了Golang中cf.Organization類的典型用法代碼示例。如果您正苦於以下問題:Golang Organization類的具體用法?Golang Organization怎麽用?Golang Organization使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Organization類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestTargetOrganizationWhenUserHasAccess
func TestTargetOrganizationWhenUserHasAccess(t *testing.T) {
orgRepo, spaceRepo, configRepo, reqFactory := getTargetDependencies()
configRepo.Login()
config, err := configRepo.Get()
assert.NoError(t, err)
config.SpaceFields = cf.SpaceFields{}
config.SpaceFields.Name = "my-space"
config.SpaceFields.Guid = "my-space-guid"
org := cf.Organization{}
org.Name = "my-organization"
org.Guid = "my-organization-guid"
orgRepo.Organizations = []cf.Organization{org}
orgRepo.FindByNameOrganization = org
ui := callTarget([]string{"-o", "my-organization"}, reqFactory, configRepo, orgRepo, spaceRepo)
assert.Equal(t, orgRepo.FindByNameName, "my-organization")
assert.True(t, ui.ShowConfigurationCalled)
savedConfig := testconfig.SavedConfiguration
assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-organization-guid")
}
示例2: TestDeleteUntargetedOrganizationDoesNotClearConfig
func TestDeleteUntargetedOrganizationDoesNotClearConfig(t *testing.T) {
org := cf.Organization{}
org.Name = "org-to-delete"
org.Guid = "org-to-delete-guid"
orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}
configRepo := &testconfig.FakeConfigRepository{}
config, _ := configRepo.Get()
otherOrgFields := cf.OrganizationFields{}
otherOrgFields.Guid = "some-other-org-guid"
otherOrgFields.Name = "some-other-org"
config.OrganizationFields = otherOrgFields
spaceFields := cf.SpaceFields{}
spaceFields.Name = "some-other-space"
config.SpaceFields = spaceFields
configRepo.Save()
deleteOrg(t, "Yes", []string{"org-to-delete"}, orgRepo)
updatedConfig, err := configRepo.Get()
assert.NoError(t, err)
assert.Equal(t, updatedConfig.OrganizationFields.Name, "some-other-org")
assert.Equal(t, updatedConfig.SpaceFields.Name, "some-other-space")
}
示例3: TestTargetOrganizationAndSpace
func TestTargetOrganizationAndSpace(t *testing.T) {
orgRepo, spaceRepo, configRepo, reqFactory := getTargetDependencies()
configRepo.Delete()
configRepo.Login()
org := cf.Organization{}
org.Name = "my-organization"
org.Guid = "my-organization-guid"
orgRepo.FindByNameOrganization = org
space := cf.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
spaceRepo.FindByNameSpace = space
ui := callTarget([]string{"-o", "my-organization", "-s", "my-space"}, reqFactory, configRepo, orgRepo, spaceRepo)
savedConfig := testconfig.SavedConfiguration
assert.True(t, ui.ShowConfigurationCalled)
assert.Equal(t, orgRepo.FindByNameName, "my-organization")
assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-organization-guid")
assert.Equal(t, spaceRepo.FindByNameName, "my-space")
assert.Equal(t, savedConfig.SpaceFields.Guid, "my-space-guid")
}
示例4: TestDeleteTargetedOrganizationClearsConfig
func TestDeleteTargetedOrganizationClearsConfig(t *testing.T) {
configRepo := &testconfig.FakeConfigRepository{}
config, _ := configRepo.Get()
organizationFields := cf.OrganizationFields{}
organizationFields.Name = "org-to-delete"
organizationFields.Guid = "org-to-delete-guid"
config.OrganizationFields = organizationFields
spaceFields := cf.SpaceFields{}
spaceFields.Name = "space-to-delete"
config.SpaceFields = spaceFields
configRepo.Save()
org := cf.Organization{}
org.OrganizationFields = organizationFields
orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}
deleteOrg(t, "Yes", []string{"org-to-delete"}, orgRepo)
updatedConfig, err := configRepo.Get()
assert.NoError(t, err)
assert.Equal(t, updatedConfig.OrganizationFields, cf.OrganizationFields{})
assert.Equal(t, updatedConfig.SpaceFields, cf.SpaceFields{})
}
示例5: TestSetSpaceRole
func TestSetSpaceRole(t *testing.T) {
org := cf.Organization{}
org.Guid = "my-org-guid"
org.Name = "my-org"
args := []string{"some-user", "some-org", "some-space", "SpaceManager"}
reqFactory, spaceRepo, userRepo := getSetSpaceRoleDeps()
reqFactory.LoginSuccess = true
reqFactory.UserFields = cf.UserFields{}
reqFactory.UserFields.Guid = "my-user-guid"
reqFactory.UserFields.Username = "my-user"
reqFactory.Organization = org
spaceRepo.FindByNameInOrgSpace = cf.Space{}
spaceRepo.FindByNameInOrgSpace.Guid = "my-space-guid"
spaceRepo.FindByNameInOrgSpace.Name = "my-space"
spaceRepo.FindByNameInOrgSpace.Organization = org.OrganizationFields
ui := callSetSpaceRole(t, args, reqFactory, spaceRepo, userRepo)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Assigning role ", "SpaceManager", "my-user", "my-org", "my-space", "current-user"},
{"OK"},
})
assert.Equal(t, spaceRepo.FindByNameInOrgName, "some-space")
assert.Equal(t, spaceRepo.FindByNameInOrgOrgGuid, "my-org-guid")
assert.Equal(t, userRepo.SetSpaceRoleUserGuid, "my-user-guid")
assert.Equal(t, userRepo.SetSpaceRoleSpaceGuid, "my-space-guid")
assert.Equal(t, userRepo.SetSpaceRoleRole, cf.SPACE_MANAGER)
}
示例6: TestUnsetOrgRole
func TestUnsetOrgRole(t *testing.T) {
userRepo := &testapi.FakeUserRepository{}
user := cf.UserFields{}
user.Username = "some-user"
user.Guid = "some-user-guid"
org := cf.Organization{}
org.Name = "some-org"
org.Guid = "some-org-guid"
reqFactory := &testreq.FakeReqFactory{
LoginSuccess: true,
UserFields: user,
Organization: org,
}
args := []string{"my-username", "my-org", "OrgManager"}
ui := callUnsetOrgRole(t, args, userRepo, reqFactory)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Removing role", "OrgManager", "my-username", "my-org", "current-user"},
{"OK"},
})
assert.Equal(t, userRepo.UnsetOrgRoleRole, cf.ORG_MANAGER)
assert.Equal(t, userRepo.UnsetOrgRoleUserGuid, "some-user-guid")
assert.Equal(t, userRepo.UnsetOrgRoleOrganizationGuid, "some-org-guid")
}
示例7: TestTargetOrganizationAndSpaceWhenSpaceFails
func TestTargetOrganizationAndSpaceWhenSpaceFails(t *testing.T) {
orgRepo, spaceRepo, configRepo, reqFactory := getTargetDependencies()
configRepo.Delete()
configRepo.Login()
org := cf.Organization{}
org.Name = "my-organization"
org.Guid = "my-organization-guid"
orgRepo.FindByNameOrganization = org
spaceRepo.FindByNameErr = true
ui := callTarget([]string{"-o", "my-organization", "-s", "my-space"}, reqFactory, configRepo, orgRepo, spaceRepo)
savedConfig := testconfig.SavedConfiguration
assert.True(t, ui.ShowConfigurationCalled)
assert.Equal(t, orgRepo.FindByNameName, "my-organization")
assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-organization-guid")
assert.Equal(t, spaceRepo.FindByNameName, "my-space")
assert.Equal(t, savedConfig.SpaceFields.Guid, "")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"FAILED"},
{"Unable to access space", "my-space"},
})
}
示例8: TestSuccessfullyLoggingInWithOnlyOneOrg
func TestSuccessfullyLoggingInWithOnlyOneOrg(t *testing.T) {
org := cf.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
c := LoginTestContext{
Flags: []string{"-s", "my-space"},
Inputs: []string{"http://api.example.com", "[email protected]", "password"},
}
callLogin(t, &c, func(c *LoginTestContext) {
c.orgRepo.FindByNameOrganization = cf.Organization{}
c.orgRepo.Organizations = []cf.Organization{org}
})
savedConfig := testconfig.SavedConfiguration
assert.Equal(t, savedConfig.Target, "http://api.example.com")
assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-org-guid")
assert.Equal(t, savedConfig.SpaceFields.Guid, "my-space-guid")
assert.Equal(t, savedConfig.AccessToken, "my_access_token")
assert.Equal(t, savedConfig.RefreshToken, "my_refresh_token")
assert.Equal(t, c.endpointRepo.UpdateEndpointReceived, "http://api.example.com")
assert.Equal(t, c.authRepo.Email, "[email protected]")
assert.Equal(t, c.authRepo.Password, "password")
assert.True(t, c.ui.ShowConfigurationCalled)
}
示例9: TestLoggingInWithTooManyOrgsDoesNotShowOrgList
func TestLoggingInWithTooManyOrgsDoesNotShowOrgList(t *testing.T) {
c := LoginTestContext{
Inputs: []string{"api.example.com", "[email protected]", "password", "my-org-1", "my-space"},
}
callLogin(t, &c, func(c *LoginTestContext) {
for i := 0; i < 60; i++ {
id := strconv.Itoa(i)
org := cf.Organization{}
org.Guid = "my-org-guid-" + id
org.Name = "my-org-" + id
c.orgRepo.Organizations = append(c.orgRepo.Organizations, org)
}
c.orgRepo.FindByNameOrganization = c.orgRepo.Organizations[1]
space1 := cf.Space{}
space1.Guid = "my-space-guid"
space1.Name = "my-space"
space2 := cf.Space{}
space2.Guid = "some-space-guid"
space2.Name = "some-space"
c.spaceRepo.Spaces = []cf.Space{space1, space2}
})
savedConfig := testconfig.SavedConfiguration
testassert.SliceDoesNotContain(t, c.ui.Outputs, testassert.Lines{
{"my-org-2"},
})
assert.Equal(t, c.orgRepo.FindByNameName, "my-org-1")
assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-org-guid-1")
}
示例10: TestOrgReqExecute
func TestOrgReqExecute(t *testing.T) {
org := cf.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}
ui := new(testterm.FakeUI)
orgReq := newOrganizationRequirement("foo", ui, orgRepo)
success := orgReq.Execute()
assert.True(t, success)
assert.Equal(t, orgRepo.FindByNameName, "foo")
assert.Equal(t, orgReq.GetOrganization(), org)
}
示例11: TestShowOrgFailsWithUsage
func TestShowOrgFailsWithUsage(t *testing.T) {
org := cf.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
reqFactory := &testreq.FakeReqFactory{Organization: org, LoginSuccess: true}
args := []string{"my-org"}
ui := callShowOrg(t, args, reqFactory)
assert.False(t, ui.FailedWithUsage)
args = []string{}
ui = callShowOrg(t, args, reqFactory)
assert.True(t, ui.FailedWithUsage)
}
示例12: TestCreateDomain
func TestCreateDomain(t *testing.T) {
org := cf.Organization{}
org.Name = "myOrg"
org.Guid = "myOrg-guid"
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Organization: org}
domainRepo := &testapi.FakeDomainRepository{}
ui := callCreateDomain(t, []string{"myOrg", "example.com"}, reqFactory, domainRepo)
assert.Equal(t, domainRepo.CreateDomainName, "example.com")
assert.Equal(t, domainRepo.CreateDomainOwningOrgGuid, "myOrg-guid")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Creating domain", "example.com", "myOrg", "my-user"},
{"OK"},
})
}
示例13: TestDeleteOrgWithForceOption
func TestDeleteOrgWithForceOption(t *testing.T) {
org := cf.Organization{}
org.Name = "org-to-delete"
org.Guid = "org-to-delete-guid"
orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}
ui := deleteOrg(t, "Yes", []string{"-f", "org-to-delete"}, orgRepo)
assert.Equal(t, len(ui.Prompts), 0)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Deleting", "org-to-delete"},
{"OK"},
})
assert.Equal(t, orgRepo.FindByNameName, "org-to-delete")
assert.Equal(t, orgRepo.DeletedOrganizationGuid, "org-to-delete-guid")
}
示例14: TestOrganizationsFindByName
func TestOrganizationsFindByName(t *testing.T) {
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/organizations?q=name%3Aorg1&inline-relations-depth=1",
Response: testnet.TestResponse{Status: http.StatusOK, Body: `{"resources": [{
"metadata": { "guid": "org1-guid" },
"entity": {
"name": "Org1",
"quota_definition": {
"entity": {
"name": "not-your-average-quota",
"memory_limit": 128
}
},
"spaces": [{
"metadata": { "guid": "space1-guid" },
"entity": { "name": "Space1" }
}],
"domains": [{
"metadata": { "guid": "domain1-guid" },
"entity": { "name": "cfapps.io" }
}]
}
}]}`},
})
ts, handler, repo := createOrganizationRepo(t, req)
defer ts.Close()
existingOrg := cf.Organization{}
existingOrg.Guid = "org1-guid"
existingOrg.Name = "Org1"
org, apiResponse := repo.FindByName("Org1")
assert.True(t, handler.AllRequestsCalled())
assert.False(t, apiResponse.IsNotSuccessful())
assert.Equal(t, org.Name, existingOrg.Name)
assert.Equal(t, org.Guid, existingOrg.Guid)
assert.Equal(t, org.QuotaDefinition.Name, "not-your-average-quota")
assert.Equal(t, org.QuotaDefinition.MemoryLimit, uint64(128))
assert.Equal(t, len(org.Spaces), 1)
assert.Equal(t, org.Spaces[0].Name, "Space1")
assert.Equal(t, org.Spaces[0].Guid, "space1-guid")
assert.Equal(t, len(org.Domains), 1)
assert.Equal(t, org.Domains[0].Name, "cfapps.io")
assert.Equal(t, org.Domains[0].Guid, "domain1-guid")
}
示例15: TestRenameOrgRun
func TestRenameOrgRun(t *testing.T) {
orgRepo := &testapi.FakeOrgRepository{}
org := cf.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Organization: org}
ui := callRenameOrg(t, []string{"my-org", "my-new-org"}, reqFactory, orgRepo)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Renaming org", "my-org", "my-new-org", "my-user"},
{"OK"},
})
assert.Equal(t, orgRepo.RenameOrganizationGuid, "my-org-guid")
assert.Equal(t, orgRepo.RenameNewName, "my-new-org")
}