本文整理匯總了Golang中cf.Domain.Shared方法的典型用法代碼示例。如果您正苦於以下問題:Golang Domain.Shared方法的具體用法?Golang Domain.Shared怎麽用?Golang Domain.Shared使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf.Domain
的用法示例。
在下文中一共展示了Domain.Shared方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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"},
})
}
示例2: findAllWithPath
func (repo CloudControllerDomainRepository) findAllWithPath(path string) (domains []cf.Domain, apiResponse net.ApiResponse) {
domainResources := new(PaginatedDomainResources)
apiResponse = repo.gateway.GetResource(path, repo.config.AccessToken, domainResources)
if apiResponse.IsNotSuccessful() {
return
}
for _, r := range domainResources.Resources {
domain := cf.Domain{
Name: r.Entity.Name,
Guid: r.Metadata.Guid,
}
domain.Shared = r.Entity.OwningOrganizationGuid == ""
for _, space := range r.Entity.Spaces {
domain.Spaces = append(domain.Spaces, cf.Space{
Name: space.Entity.Name,
Guid: space.Metadata.Guid,
})
}
domains = append(domains, domain)
}
return
}
示例3: TestPushingAppWhenItAlreadyExistsWithoutARouteCreatesADefaultDomain
func TestPushingAppWhenItAlreadyExistsWithoutARouteCreatesADefaultDomain(t *testing.T) {
deps := getPushDependencies()
sharedDomain := cf.Domain{}
sharedDomain.Name = "foo.cf-app.com"
sharedDomain.Shared = true
sharedDomain.Guid = "foo-domain-guid"
deps.routeRepo.FindByHostAndDomainErr = true
deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{sharedDomain}
deps.appRepo.ReadApp = maker.NewApp(maker.Overrides{"name": "existing-app", "guid": "existing-app-guid"})
deps.appRepo.UpdateAppResult = deps.appRepo.ReadApp
ui := callPush(t, []string{"-t", "111", "existing-app"}, deps)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Creating route", "existing-app.foo.cf-app.com"},
{"OK"},
{"Binding", "existing-app.foo.cf-app.com"},
{"OK"},
{"Uploading"},
{"OK"},
})
assert.Equal(t, deps.routeRepo.FindByHostAndDomainDomain, "foo.cf-app.com")
assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "existing-app")
assert.Equal(t, deps.routeRepo.CreatedHost, "existing-app")
assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "foo-domain-guid")
assert.Equal(t, deps.routeRepo.BoundAppGuid, "existing-app-guid")
assert.Equal(t, deps.routeRepo.BoundRouteGuid, "existing-app-route-guid")
}
示例4: TestPushingAppWhenItAlreadyExistsAndHostIsSpecified
func TestPushingAppWhenItAlreadyExistsAndHostIsSpecified(t *testing.T) {
deps := getPushDependencies()
domain := cf.Domain{}
domain.Name = "example.com"
domain.Guid = "domain-guid"
domain.Shared = true
existingRoute := cf.RouteSummary{}
existingRoute.Host = "existing-app"
existingRoute.Domain = domain.DomainFields
existingApp := cf.Application{}
existingApp.Name = "existing-app"
existingApp.Guid = "existing-app-guid"
existingApp.Routes = []cf.RouteSummary{existingRoute}
deps.appRepo.ReadApp = existingApp
deps.appRepo.UpdateAppResult = existingApp
deps.routeRepo.FindByHostAndDomainNotFound = true
deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{domain}
ui := callPush(t, []string{"-n", "new-host", "existing-app"}, deps)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Creating route", "new-host.example.com"},
{"OK"},
{"Binding", "new-host.example.com"},
})
assert.Equal(t, deps.routeRepo.FindByHostAndDomainDomain, "example.com")
assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "new-host")
assert.Equal(t, deps.routeRepo.CreatedHost, "new-host")
assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "domain-guid")
}
示例5: TestPushingAppWhenItDoesNotExistButRouteExists
func TestPushingAppWhenItDoesNotExistButRouteExists(t *testing.T) {
deps := getPushDependencies()
domain := cf.Domain{}
domain.Name = "foo.cf-app.com"
domain.Guid = "foo-domain-guid"
domain.Shared = true
route := cf.Route{}
route.Guid = "my-route-guid"
route.Host = "my-new-app"
route.Domain = domain.DomainFields
deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{domain}
deps.routeRepo.FindByHostAndDomainRoute = route
deps.appRepo.ReadNotFound = true
ui := callPush(t, []string{"my-new-app"}, deps)
assert.Empty(t, deps.routeRepo.CreatedHost)
assert.Empty(t, deps.routeRepo.CreatedDomainGuid)
assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "my-new-app")
assert.Equal(t, deps.routeRepo.BoundAppGuid, "my-new-app-guid")
assert.Equal(t, deps.routeRepo.BoundRouteGuid, "my-route-guid")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Using", "my-new-app.foo.cf-app.com"},
{"Binding", "my-new-app.foo.cf-app.com"},
{"OK"},
})
}
示例6: TestPushingAppWhenItDoesNotExist
func TestPushingAppWhenItDoesNotExist(t *testing.T) {
deps := getPushDependencies()
domain := cf.Domain{}
domain.Guid = "not-the-right-guid"
domain.Name = "not shared domain"
domain.OwningOrganizationGuid = "my-org-guid"
sharedDomain := cf.Domain{}
sharedDomain.Name = "foo.cf-app.com"
sharedDomain.Shared = true
sharedDomain.Guid = "foo-domain-guid"
appRepo := deps.appRepo
domainRepo := deps.domainRepo
routeRepo := deps.routeRepo
appBitsRepo := deps.appBitsRepo
stopper := deps.stopper
starter := deps.starter
domainRepo.ListDomainsForOrgDomains = []cf.Domain{domain, sharedDomain}
routeRepo.FindByHostAndDomainErr = true
appRepo.ReadNotFound = true
ui := callPush(t, []string{"-t", "111", "my-new-app"}, deps)
assert.Equal(t, appRepo.CreatedAppParams().Get("name").(string), "my-new-app")
assert.Equal(t, appRepo.CreatedAppParams().Get("space_guid").(string), "my-space-guid")
assert.Equal(t, routeRepo.FindByHostAndDomainHost, "my-new-app")
assert.Equal(t, routeRepo.CreatedHost, "my-new-app")
assert.Equal(t, routeRepo.CreatedDomainGuid, "foo-domain-guid")
assert.Equal(t, routeRepo.BoundAppGuid, "my-new-app-guid")
assert.Equal(t, routeRepo.BoundRouteGuid, "my-new-app-route-guid")
assert.Equal(t, appBitsRepo.UploadedAppGuid, "my-new-app-guid")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Creating app", "my-new-app", "my-org", "my-space"},
{"OK"},
{"Creating", "my-new-app.foo.cf-app.com"},
{"OK"},
{"Binding", "my-new-app.foo.cf-app.com"},
{"OK"},
{"Uploading my-new-app"},
{"OK"},
})
assert.Equal(t, stopper.AppToStop.Guid, "")
assert.Equal(t, starter.AppToStart.Guid, "my-new-app-guid")
assert.Equal(t, starter.AppToStart.Name, "my-new-app")
assert.Equal(t, starter.Timeout, 111)
}
示例7: TestPushingAppWithNoHostname
func TestPushingAppWithNoHostname(t *testing.T) {
deps := getPushDependencies()
domain := cf.Domain{}
domain.Name = "bar.cf-app.com"
domain.Guid = "bar-domain-guid"
domain.Shared = true
deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{domain}
deps.routeRepo.FindByHostAndDomainErr = true
deps.appRepo.ReadNotFound = true
callPush(t, []string{
"--no-hostname",
"my-new-app",
}, deps)
assert.Equal(t, deps.appRepo.CreatedAppParams().Get("name").(string), "my-new-app")
assert.Equal(t, deps.routeRepo.CreatedHost, "")
assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "bar-domain-guid")
}
示例8: TestDeleteDomainForceFlagSkipsConfirmation
func TestDeleteDomainForceFlagSkipsConfirmation(t *testing.T) {
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
domain := cf.Domain{}
domain.Name = "foo.com"
domain.Guid = "foo-guid"
domain.Shared = true
domainRepo := &testapi.FakeDomainRepository{
FindByNameInOrgDomain: domain,
}
ui := callDeleteDomain(t, []string{"-f", "foo.com"}, []string{}, reqFactory, domainRepo)
assert.Equal(t, domainRepo.DeleteDomainGuid, "foo-guid")
assert.Equal(t, len(ui.Prompts), 0)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Deleting domain", "foo.com"},
{"OK"},
})
}
示例9: TestPushingAppWithACrazyName
func TestPushingAppWithACrazyName(t *testing.T) {
deps := getPushDependencies()
sharedDomain := cf.Domain{}
sharedDomain.Name = "foo.cf-app.com"
sharedDomain.Shared = true
sharedDomain.Guid = "foo-domain-guid"
deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{sharedDomain}
deps.routeRepo.FindByHostAndDomainErr = true
deps.appRepo.ReadNotFound = true
ui := callPush(t, []string{"-t", "111", "Tim's 1st-Crazy__app!"}, deps)
assert.Equal(t, deps.appRepo.CreatedAppParams().Get("name"), "Tim's 1st-Crazy__app!")
assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "tims-1st-crazy-app")
assert.Equal(t, deps.routeRepo.CreatedHost, "tims-1st-crazy-app")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Creating", "tims-1st-crazy-app.foo.cf-app.com"},
{"Binding", "tims-1st-crazy-app.foo.cf-app.com"},
})
}