本文整理匯總了Golang中cf.OrganizationFields.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang OrganizationFields.Name方法的具體用法?Golang OrganizationFields.Name怎麽用?Golang OrganizationFields.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf.OrganizationFields
的用法示例。
在下文中一共展示了OrganizationFields.Name方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestListingSpaces
func TestListingSpaces(t *testing.T) {
space := cf.Space{}
space.Name = "space1"
space2 := cf.Space{}
space2.Name = "space2"
space3 := cf.Space{}
space3.Name = "space3"
spaceRepo := &testapi.FakeSpaceRepository{
Spaces: []cf.Space{space, space2, space3},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
config := &configuration.Configuration{
OrganizationFields: org,
AccessToken: token,
}
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
ui := callSpaces([]string{}, reqFactory, config, spaceRepo)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Getting spaces in org", "my-org", "my-user"},
{"space1"},
{"space2"},
{"space3"},
})
}
示例2: TestListDomains
func TestListDomains(t *testing.T) {
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
orgFields.Guid = "my-org-guid"
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, OrganizationFields: orgFields}
domain1 := cf.Domain{}
domain1.Shared = true
domain1.Name = "Domain1"
domain2 := cf.Domain{}
domain2.Shared = false
domain2.Name = "Domain2"
domain3 := cf.Domain{}
domain3.Shared = false
domain3.Name = "Domain3"
domainRepo := &testapi.FakeDomainRepository{
ListSharedDomainsDomains: []cf.Domain{domain1},
ListDomainsForOrgDomains: []cf.Domain{domain2, domain3},
}
ui := callListDomains(t, []string{}, reqFactory, domainRepo)
assert.Equal(t, domainRepo.ListDomainsForOrgDomainsGuid, "my-org-guid")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Getting domains in org", "my-org", "my-user"},
{"name", "status"},
{"Domain1", "shared"},
{"Domain2", "owned"},
{"Domain3", "owned"},
})
}
示例3: TestSuccessfullyLoggingInWithOrgSetInConfig
func TestSuccessfullyLoggingInWithOrgSetInConfig(t *testing.T) {
org := cf.OrganizationFields{}
org.Name = "my-org"
org.Guid = "my-org-guid"
existingConfig := configuration.Configuration{OrganizationFields: org}
c := LoginTestContext{
Flags: []string{"-s", "my-space"},
Inputs: []string{"http://api.example.com", "[email protected]", "password"},
Config: existingConfig,
}
callLogin(t, &c, func(c *LoginTestContext) {
c.orgRepo.FindByNameOrganization = cf.Organization{}
})
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)
}
示例4: callListRoutes
func callListRoutes(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory, routeRepo *testapi.FakeRouteRepository) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{}
ctxt := testcmd.NewContext("routes", args)
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
space := cf.SpaceFields{}
space.Name = "my-space"
org := cf.OrganizationFields{}
org.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
cmd := NewListRoutes(ui, config, routeRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例5: deleteApp
func deleteApp(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, appRepo *testapi.FakeApplicationRepository) {
app := cf.Application{}
app.Name = "app-to-delete"
app.Guid = "app-to-delete-guid"
reqFactory = &testreq.FakeReqFactory{}
appRepo = &testapi.FakeApplicationRepository{ReadApp: app}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
ctxt := testcmd.NewContext("delete", args)
cmd := NewDeleteApp(ui, config, appRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例6: TestLogoutClearsAccessTokenOrgAndSpace
func TestLogoutClearsAccessTokenOrgAndSpace(t *testing.T) {
org := cf.OrganizationFields{}
org.Name = "MyOrg"
space := cf.SpaceFields{}
space.Name = "MySpace"
configRepo := &testconfig.FakeConfigRepository{}
config, _ := configRepo.Get()
config.AccessToken = "MyAccessToken"
config.OrganizationFields = org
config.SpaceFields = space
ui := new(testterm.FakeUI)
l := commands.NewLogout(ui, configRepo)
l.Run(nil)
updatedConfig, err := configRepo.Get()
assert.NoError(t, err)
assert.Empty(t, updatedConfig.AccessToken)
assert.Equal(t, updatedConfig.OrganizationFields, cf.OrganizationFields{})
assert.Equal(t, updatedConfig.SpaceFields, cf.SpaceFields{})
}
示例7: deleteServiceBroker
func deleteServiceBroker(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, repo *testapi.FakeServiceBrokerRepo) {
serviceBroker := cf.ServiceBroker{}
serviceBroker.Name = "service-broker-to-delete"
serviceBroker.Guid = "service-broker-to-delete-guid"
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true}
repo = &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
space2 := cf.SpaceFields{}
space2.Name = "my-space"
org2 := cf.OrganizationFields{}
org2.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: space2,
OrganizationFields: org2,
AccessToken: token,
}
ctxt := testcmd.NewContext("delete-service-broker", args)
cmd := NewDeleteServiceBroker(ui, config, repo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例8: callListQuotas
func callListQuotas(t *testing.T, reqFactory *testreq.FakeReqFactory, quotaRepo *testapi.FakeQuotaRepository) (fakeUI *testterm.FakeUI) {
fakeUI = &testterm.FakeUI{}
ctxt := testcmd.NewContext("quotas", []string{})
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := organization.NewListQuotas(fakeUI, config, quotaRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例9: callDeleteDomain
func callDeleteDomain(t *testing.T, args []string, inputs []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (ui *testterm.FakeUI) {
ctxt := testcmd.NewContext("delete-domain", args)
ui = &testterm.FakeUI{
Inputs: inputs,
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := domain.NewDeleteDomain(ui, config, domainRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例10: TestUpdateEndpointWhenUrlIsAlreadyTargeted
func TestUpdateEndpointWhenUrlIsAlreadyTargeted(t *testing.T) {
configRepo := testconfig.FakeConfigRepository{}
configRepo.Delete()
configRepo.Login()
ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
defer ts.Close()
org := cf.OrganizationFields{}
org.Name = "my-org"
org.Guid = "my-org-guid"
space := cf.SpaceFields{}
space.Name = "my-space"
space.Guid = "my-space-guid"
config, _ := configRepo.Get()
config.Target = ts.URL
config.AccessToken = "some access token"
config.RefreshToken = "some refresh token"
config.OrganizationFields = org
config.SpaceFields = space
repo.UpdateEndpoint(ts.URL)
assert.Equal(t, config.OrganizationFields, org)
assert.Equal(t, config.SpaceFields, space)
assert.Equal(t, config.AccessToken, "some access token")
assert.Equal(t, config.RefreshToken, "some refresh token")
}
示例11: TestClearSession
func TestClearSession(t *testing.T) {
withFakeHome(t, func() {
repo := NewConfigurationDiskRepository()
config, err := repo.Get()
assert.NoError(t, err)
config.Target = "http://api.example.com"
config.RefreshToken = "some old refresh token"
config.AccessToken = "some old access token"
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
repo.Save()
err = repo.ClearSession()
assert.NoError(t, err)
repo.Save()
savedConfig, err := repo.Get()
assert.NoError(t, err)
assert.Equal(t, savedConfig.Target, "http://api.example.com")
assert.Empty(t, savedConfig.AccessToken)
assert.Empty(t, savedConfig.RefreshToken)
assert.Equal(t, savedConfig.OrganizationFields, cf.OrganizationFields{})
assert.Equal(t, savedConfig.SpaceFields, cf.SpaceFields{})
})
}
示例12: TestClearTokens
func TestClearTokens(t *testing.T) {
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
repo := NewConfigurationDiskRepository()
config := repo.loadDefaultConfig(t)
defer repo.restoreConfig(t)
config.Target = "http://api.example.com"
config.RefreshToken = "some old refresh token"
config.AccessToken = "some old access token"
config.OrganizationFields = org
config.SpaceFields = space
repo.Save()
err := repo.ClearTokens()
assert.NoError(t, err)
repo.Save()
savedConfig, err := repo.Get()
assert.NoError(t, err)
assert.Equal(t, savedConfig.Target, "http://api.example.com")
assert.Empty(t, savedConfig.AccessToken)
assert.Empty(t, savedConfig.RefreshToken)
assert.Equal(t, savedConfig.OrganizationFields, org)
assert.Equal(t, savedConfig.SpaceFields, space)
}
示例13: callRenameService
func callRenameService(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI, serviceRepo *testapi.FakeServiceRepo) {
ui = &testterm.FakeUI{}
serviceRepo = &testapi.FakeServiceRepo{}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
cmd := NewRenameService(ui, config, serviceRepo)
ctxt := testcmd.NewContext("rename-service", args)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例14: deleteWithConfirmation
func deleteWithConfirmation(t *testing.T, confirmation string) (ui *testterm.FakeUI, userRepo *testapi.FakeUserRepository) {
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
user2 := cf.UserFields{}
user2.Username = "my-found-user"
user2.Guid = "my-found-user-guid"
userRepo = &testapi.FakeUserRepository{
FindByUsernameUserFields: user2,
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "current-user",
})
assert.NoError(t, err)
org2 := cf.OrganizationFields{}
org2.Name = "my-org"
space2 := cf.SpaceFields{}
space2.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space2,
OrganizationFields: org2,
AccessToken: token,
}
cmd := NewDeleteUser(ui, config, userRepo)
ctxt := testcmd.NewContext("delete-user", []string{"my-user"})
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例15: callDomainMapper
func callDomainMapper(t *testing.T, shouldMap bool, args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (ui *testterm.FakeUI) {
cmdName := "map-domain"
if !shouldMap {
cmdName = "unmap-domain"
}
ctxt := testcmd.NewContext(cmdName, args)
ui = &testterm.FakeUI{}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := domain.NewDomainMapper(ui, config, domainRepo, shouldMap)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}