本文整理匯總了Golang中cf.Organization.Guid方法的典型用法代碼示例。如果您正苦於以下問題:Golang Organization.Guid方法的具體用法?Golang Organization.Guid怎麽用?Golang Organization.Guid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf.Organization
的用法示例。
在下文中一共展示了Organization.Guid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestSuccessfullyLoggingInWithNumericalPrompts
func TestSuccessfullyLoggingInWithNumericalPrompts(t *testing.T) {
OUT_OF_RANGE_CHOICE := "3"
c := LoginTestContext{
Inputs: []string{"api.example.com", "[email protected]", "password", OUT_OF_RANGE_CHOICE, "2", OUT_OF_RANGE_CHOICE, "1"},
}
org1 := cf.Organization{}
org1.Guid = "some-org-guid"
org1.Name = "some-org"
org2 := cf.Organization{}
org2.Guid = "my-org-guid"
org2.Name = "my-org"
space1 := cf.Space{}
space1.Guid = "my-space-guid"
space1.Name = "my-space"
space2 := cf.Space{}
space2.Guid = "some-space-guid"
space2.Name = "some-space"
callLogin(t, &c, func(c *LoginTestContext) {
c.orgRepo.Organizations = []cf.Organization{org1, org2}
c.spaceRepo.Spaces = []cf.Space{space1, space2}
})
savedConfig := testconfig.SavedConfiguration
expectedOutputs := testassert.Lines{
testassert.Line{"Select an org:"},
testassert.Line{"1. some-org"},
testassert.Line{"2. my-org"},
testassert.Line{"Select a space:"},
testassert.Line{"1. my-space"},
testassert.Line{"2. some-space"},
}
testassert.SliceContains(t, c.ui.Outputs, expectedOutputs)
assert.Equal(t, savedConfig.Target, "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, "api.example.com")
assert.Equal(t, c.authRepo.Email, "[email protected]")
assert.Equal(t, c.authRepo.Password, "password")
assert.Equal(t, c.orgRepo.FindByNameName, "my-org")
assert.Equal(t, c.spaceRepo.FindByNameName, "my-space")
assert.True(t, c.ui.ShowConfigurationCalled)
}
示例2: TestRunWhenOrganizationExists
func TestRunWhenOrganizationExists(t *testing.T) {
developmentSpaceFields := cf.SpaceFields{}
developmentSpaceFields.Name = "development"
stagingSpaceFields := cf.SpaceFields{}
stagingSpaceFields.Name = "staging"
domainFields := cf.DomainFields{}
domainFields.Name = "cfapps.io"
cfAppDomainFields := cf.DomainFields{}
cfAppDomainFields.Name = "cf-app.com"
org := cf.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
org.QuotaDefinition = cf.NewQuotaFields("cantina-quota", 512)
org.Spaces = []cf.SpaceFields{developmentSpaceFields, stagingSpaceFields}
org.Domains = []cf.DomainFields{domainFields, cfAppDomainFields}
reqFactory := &testreq.FakeReqFactory{Organization: org, LoginSuccess: true}
args := []string{"my-org"}
ui := callShowOrg(t, args, reqFactory)
assert.Equal(t, reqFactory.OrganizationName, "my-org")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Getting info for org", "my-org", "my-user"},
{"OK"},
{"my-org"},
{" domains:", "cfapps.io", "cf-app.com"},
{" quota: ", "cantina-quota", "512M"},
{" spaces:", "development", "staging"},
})
}
示例3: 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")
}
示例4: 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")
}
示例5: 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")
}
示例6: 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")
}
示例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: 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)
}
示例9: 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)
}
示例10: 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")
}
示例11: 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)
}
示例12: 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)
}
示例13: 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"},
})
}
示例14: 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")
}
示例15: 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")
}