本文整理匯總了Golang中cf/models.Space.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Space.Name方法的具體用法?Golang Space.Name怎麽用?Golang Space.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf/models.Space
的用法示例。
在下文中一共展示了Space.Name方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setUpLoginTestContext
func setUpLoginTestContext() (c *LoginTestContext) {
c = new(LoginTestContext)
c.Config = testconfig.NewRepository()
c.ui = &testterm.FakeUI{}
c.authRepo = &testapi.FakeAuthenticationRepository{
AccessToken: "my_access_token",
RefreshToken: "my_refresh_token",
Config: c.Config,
}
c.endpointRepo = &testapi.FakeEndpointRepo{Config: c.Config}
org := models.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
c.orgRepo = &testapi.FakeOrgRepository{
Organizations: []models.Organization{org},
}
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
c.spaceRepo = &testapi.FakeSpaceRepository{
Spaces: []models.Space{space},
}
return
}
示例2:
callRenameSpace([]string{"my-space", "my-new-space"})
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
})
Describe("when the user provides fewer than two args", func() {
It("fails with usage", func() {
callRenameSpace([]string{"foo"})
Expect(ui.FailedWithUsage).To(BeTrue())
})
})
Describe("when the user is logged in and has provided an old and new space name", func() {
BeforeEach(func() {
space := models.Space{}
space.Name = "the-old-space-name"
space.Guid = "the-old-space-guid"
reqFactory.Space = space
})
It("renames a space", func() {
originalSpaceName := configRepo.SpaceFields().Name
callRenameSpace([]string{"the-old-space-name", "my-new-space"})
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
{"OK"},
})
Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
Expect(spaceRepo.RenameNewName).To(Equal("my-new-space"))
示例3:
It("TestTargetSpaceWhenNoOrganizationIsSelected", func() {
config.SetOrganizationFields(models.OrganizationFields{})
ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"An org must be targeted before targeting a space"},
})
Expect(config.OrganizationFields().Guid).To(Equal(""))
})
It("TestTargetSpaceWhenUserHasAccess", func() {
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
spaceRepo.Spaces = []models.Space{space}
spaceRepo.FindByNameSpace = space
ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("TestTargetSpaceWhenUserDoesNotHaveAccess", func() {
config.SetSpaceFields(models.SpaceFields{})
spaceRepo.FindByNameErr = true
示例4:
Config: Config,
}
endpointRepo = &testapi.FakeEndpointRepo{}
org := models.Organization{}
org.Name = "my-new-org"
org.Guid = "my-new-org-guid"
orgRepo = &testapi.FakeOrgRepository{
Organizations: []models.Organization{org},
FindByNameOrganization: models.Organization{},
}
space := models.Space{}
space.Guid = "my-space-guid"
space.Name = "my-space"
spaceRepo = &testapi.FakeSpaceRepository{
Spaces: []models.Space{space},
}
authRepo.GetLoginPromptsReturns.Prompts = map[string]configuration.AuthPrompt{
"username": configuration.AuthPrompt{
DisplayName: "Username",
Type: configuration.AuthPromptTypeText,
},
"password": configuration.AuthPrompt{
DisplayName: "Password",
Type: configuration.AuthPromptTypePassword,
},
}
示例5:
app.Name = "app1"
app.Guid = "app1-guid"
apps := []models.ApplicationFields{app}
domain := models.DomainFields{}
domain.Name = "domain1"
domain.Guid = "domain1-guid"
domains := []models.DomainFields{domain}
serviceInstance := models.ServiceInstanceFields{}
serviceInstance.Name = "service1"
serviceInstance.Guid = "service1-guid"
services := []models.ServiceInstanceFields{serviceInstance}
space := models.Space{}
space.Name = "space1"
space.Organization = org
space.Applications = apps
space.Domains = domains
space.ServiceInstances = services
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, Space: space}
ui := callShowSpace([]string{"space1"}, reqFactory)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Getting info for space", "space1", "my-org", "my-user"},
{"OK"},
{"space1"},
{"Org", "my-org"},
{"Apps", "app1"},
{"Domains", "domain1"},
{"Services", "service1"},
示例6: defaultDeleteSpaceSpace
func defaultDeleteSpaceSpace() models.Space {
space := models.Space{}
space.Name = "space-to-delete"
space.Guid = "space-to-delete-guid"
return space
}
示例7:
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
callSpaces([]string{}, reqFactory, config, spaceRepo)
Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: false}
callSpaces([]string{}, reqFactory, config, spaceRepo)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
reqFactory = &testreq.FakeReqFactory{LoginSuccess: false, TargetedOrgSuccess: true}
callSpaces([]string{}, reqFactory, config, spaceRepo)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
It("TestListingSpaces", func() {
space := models.Space{}
space.Name = "space1"
space2 := models.Space{}
space2.Name = "space2"
space3 := models.Space{}
space3.Name = "space3"
spaceRepo := &testapi.FakeSpaceRepository{
Spaces: []models.Space{space, space2, space3},
}
config := testconfig.NewRepositoryWithDefaults()
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
ui := callSpaces([]string{}, reqFactory, config, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Getting spaces in org", "my-org", "my-user"},
示例8:
callSpaceUsers(args, requirementsFactory, spaceRepo, userRepo)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
requirementsFactory.LoginSuccess = true
callSpaceUsers(args, requirementsFactory, spaceRepo, userRepo)
Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
Expect("my-org").To(Equal(requirementsFactory.OrganizationName))
})
It("TestSpaceUsers", func() {
org := models.Organization{}
org.Name = "Org1"
org.Guid = "org1-guid"
space := models.Space{}
space.Name = "Space1"
space.Guid = "space1-guid"
requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: true, Organization: org}
spaceRepo := &testapi.FakeSpaceRepository{FindByNameInOrgSpace: space}
userRepo := &testapi.FakeUserRepository{}
user := models.UserFields{}
user.Username = "user1"
user2 := models.UserFields{}
user2.Username = "user2"
user3 := models.UserFields{}
user3.Username = "user3"
user4 := models.UserFields{}
user4.Username = "user4"
userRepo.ListUsersByRole = map[string][]models.UserFields{
示例9:
import (
"cf/models"
. "cf/requirements"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testterm "testhelpers/terminal"
)
var _ = Describe("Testing with ginkgo", func() {
It("TestSpaceReqExecute", func() {
space := models.Space{}
space.Name = "awesome-sauce-space"
space.Guid = "my-space-guid"
spaceRepo := &testapi.FakeSpaceRepository{Spaces: []models.Space{space}}
ui := new(testterm.FakeUI)
spaceReq := NewSpaceRequirement("awesome-sauce-space", ui, spaceRepo)
success := spaceReq.Execute()
Expect(success).To(BeTrue())
Expect(spaceRepo.FindByNameName).To(Equal("awesome-sauce-space"))
Expect(spaceReq.GetSpace()).To(Equal(space))
})
It("TestSpaceReqExecuteWhenSpaceNotFound", func() {
spaceRepo := &testapi.FakeSpaceRepository{FindByNameNotFound: true}