本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/models.Space類的典型用法代碼示例。如果您正苦於以下問題:Golang Space類的具體用法?Golang Space怎麽用?Golang Space使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Space類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
requirementsFactory.TargetedOrgSuccess = false
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"
requirementsFactory.Space = space
})
It("renames a space", func() {
originalSpaceName := configRepo.SpaceFields().Name
callRenameSpace([]string{"the-old-space-name", "my-new-space"})
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
[]string{"OK"},
))
Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
示例2:
It("fails with usage when not invoked with exactly two args", func() {
runCommand("my-org")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires arguments"},
))
})
Context("when logged in and given some users in the org and space", func() {
BeforeEach(func() {
requirementsFactory.LoginSuccess = true
org := models.Organization{}
org.Name = "Org1"
org.Guid = "org1-guid"
space := models.Space{}
space.Name = "Space1"
space.Guid = "space1-guid"
requirementsFactory.Organization = org
spaceRepo.FindByNameInOrgReturns(space, nil)
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.ListUsersInSpaceForRoleStub = func(_ string, roleName string) ([]models.UserFields, error) {
示例3:
Expect(runCommand("my-space")).To(BeFalse())
})
It("does not pass requirements if space does not exist", func() {
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
spaceReq := new(requirementsfakes.FakeSpaceRequirement)
spaceReq.ExecuteReturns(errors.New("no space"))
requirementsFactory.NewSpaceRequirementReturns(spaceReq)
Expect(runCommand("my-space")).To(BeFalse())
})
})
Describe("disallow-space-ssh", func() {
var space models.Space
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
space = models.Space{}
space.Name = "the-space-name"
space.GUID = "the-space-guid"
})
Context("when allow_ssh is already set to the false", func() {
BeforeEach(func() {
space.AllowSSH = false
spaceReq := new(requirementsfakes.FakeSpaceRequirement)
spaceReq.GetSpaceReturns(space)
示例4:
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}
securityGroup1 := models.SecurityGroupFields{Name: "Nacho Security"}
securityGroup2 := models.SecurityGroupFields{Name: "Nacho Prime"}
securityGroups := []models.SecurityGroupFields{securityGroup1, securityGroup2}
space := models.Space{}
space.Name = "whose-space-is-it-anyway"
space.Organization = org
space.Applications = apps
space.Domains = domains
space.ServiceInstances = services
space.SecurityGroups = securityGroups
space.SpaceQuotaGuid = "runaway-guid"
quota := models.SpaceQuota{}
quota.Guid = "runaway-guid"
quota.Name = "runaway"
quota.MemoryLimit = 102400
quota.InstanceMemoryLimit = -1
quota.RoutesLimit = 111
quota.ServicesLimit = 222
示例5:
app := models.ApplicationFields{}
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
requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, Space: space}
ui := callShowSpace([]string{"space1"}, requirementsFactory)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Getting info for space", "space1", "my-org", "my-user"},
[]string{"OK"},
[]string{"space1"},
[]string{"Org", "my-org"},
[]string{"Apps", "app1"},
[]string{"Domains", "domain1"},
示例6:
orgRepo.FindByNameReturns(org, nil)
config.SetOrganizationFields(models.OrganizationFields{Name: org.Name, GUID: org.GUID})
})
It("it updates the organization in the config", func() {
callTarget([]string{"-o", "my-organization"})
Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
Expect(config.OrganizationFields().GUID).To(Equal("my-organization-guid"))
})
It("updates the space in the config", func() {
space := models.Space{}
space.Name = "my-space"
space.GUID = "my-space-guid"
spaceRepo.FindByNameReturns(space, nil)
callTarget([]string{"-s", "my-space"})
Expect(spaceRepo.FindByNameCallCount()).To(Equal(1))
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))
Expect(config.SpaceFields().GUID).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("updates both the organization and the space in the config", func() {
space := models.Space{}
示例7:
Config.SetAccessToken("my_access_token")
Config.SetRefreshToken("my_refresh_token")
return nil
}
endpointRepo = new(coreconfigfakes.FakeEndpointRepository)
minCLIVersion = "1.0.0"
minRecommendedCLIVersion = "1.0.0"
org = models.Organization{}
org.Name = "my-new-org"
org.GUID = "my-new-org-guid"
orgRepo = &organizationsfakes.FakeOrganizationRepository{}
orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
space := models.Space{}
space.GUID = "my-space-guid"
space.Name = "my-space"
spaceRepo = new(apifakes.FakeSpaceRepository)
spaceRepo.ListSpacesStub = listSpacesStub([]models.Space{space})
authRepo.GetLoginPromptsAndSaveUAAServerURLReturns(map[string]coreconfig.AuthPrompt{
"username": {
DisplayName: "Username",
Type: coreconfig.AuthPromptTypeText,
},
"password": {
DisplayName: "Password",
Type: coreconfig.AuthPromptTypePassword,
},
示例8:
org.Name = "my-organization"
org.Guid = "my-organization-guid"
orgRepo.Organizations = []models.Organization{org}
orgRepo.FindByNameOrganization = org
callTarget([]string{"-o", "my-organization"})
Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
})
It("updates the space in the config", func() {
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
spaceRepo.Spaces = []models.Space{space}
spaceRepo.FindByNameSpace = space
callTarget([]string{"-s", "my-space"})
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("updates both the organization and the space in the config", func() {
org := models.Organization{}
示例9:
var _ = Describe("create-app-security-group", func() {
var (
ui *testterm.FakeUI
appSecurityGroupRepo *testapi.FakeSecurityGroup
requirementsFactory *testreq.FakeReqFactory
spaceRepo *testapi.FakeSpaceRepository
configRepo configuration.ReadWriter
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
requirementsFactory = &testreq.FakeReqFactory{}
appSecurityGroupRepo = &testapi.FakeSecurityGroup{}
configRepo = testconfig.NewRepositoryWithDefaults()
space := models.Space{}
space.Guid = "space-guid-1"
space.Name = "space-1"
space2 := models.Space{}
space2.Guid = "space-guid-2"
space2.Name = "space-2"
spaceRepo = &testapi.FakeSpaceRepository{
Spaces: []models.Space{space, space2},
}
})
runCommand := func(args ...string) {
cmd := NewCreateSecurityGroup(ui, configRepo, appSecurityGroupRepo, spaceRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
}
示例10:
Expect(orgGUID).To(Equal("org-guid"))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"Space", "space-name", "not found"},
))
})
})
Context("everything is hunky dory", func() {
BeforeEach(func() {
org := models.Organization{}
org.Name = "org-name"
org.GUID = "org-guid"
fakeOrgRepo.ListOrgsReturns([]models.Organization{org}, nil)
space := models.Space{}
space.Name = "space-name"
space.GUID = "space-guid"
fakeSpaceRepo.FindByNameInOrgReturns(space, nil)
securityGroup := models.SecurityGroup{}
securityGroup.Name = "security-group"
securityGroup.GUID = "security-group-guid"
fakeSecurityGroupRepo.ReadReturns(securityGroup, nil)
})
JustBeforeEach(func() {
runCommand("security-group", "org-name", "space-name")
})
It("assigns the security group to the space", func() {
示例11:
It("fails if we cannot obtain the target application", func() {
appRepo.ReadFromSpaceReturns(models.Application{}, errors.New("could not find target app"))
runCommand("source-app", "target-app")
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"could not find target app"},
))
})
})
})
Describe("when a space is provided, but not an org", func() {
It("send the correct target appplication for the current org and target space", func() {
space := models.Space{}
space.Name = "space-name"
space.GUID = "model-space-guid"
spaceRepo.FindByNameReturns(space, nil)
runCommand("-s", "space-name", "source-app", "target-app")
targetAppName, spaceGUID := appRepo.ReadFromSpaceArgsForCall(0)
Expect(targetAppName).To(Equal("target-app"))
Expect(spaceGUID).To(Equal("model-space-guid"))
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Copying source from app", "source-app", "to target app", "target-app", "in org my-org / space space-name as my-user..."},
[]string{"Note: this may take some time"},
[]string{"OK"},
))
示例12:
}
}
return nil
}
}
Describe("when invoked by a plugin", func() {
var (
pluginModels []plugin_models.GetSpaces_Model
)
BeforeEach(func() {
pluginModels = []plugin_models.GetSpaces_Model{}
deps.PluginModels.Spaces = &pluginModels
space := models.Space{}
space.Name = "space1"
space.Guid = "123"
space2 := models.Space{}
space2.Name = "space2"
space2.Guid = "456"
spaceRepo.ListSpacesStub = listSpacesStub([]models.Space{space, space2})
requirementsFactory.TargetedOrgSuccess = true
requirementsFactory.LoginSuccess = true
})
It("populates the plugin models upon execution", func() {
testcmd.RunCliCommand("spaces", []string{}, requirementsFactory, updateCommandDependency, true)
runCommand()
示例13:
It("fails if we cannot obtain the target application", func() {
appRepo.ReadFromSpaceReturns(models.Application{}, errors.New("could not find target app"))
runCommand("source-app", "target-app")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"could not find target app"},
))
})
})
})
Describe("when a space is provided, but not an org", func() {
It("send the correct target appplication for the current org and target space", func() {
space := models.Space{}
space.Name = "space-name"
space.Guid = "model-space-guid"
spaceRepo.FindByNameReturns(space, nil)
runCommand("-s", "space-name", "source-app", "target-app")
targetAppName, spaceGuid := appRepo.ReadFromSpaceArgsForCall(0)
Expect(targetAppName).To(Equal("target-app"))
Expect(spaceGuid).To(Equal("model-space-guid"))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Copying source from app", "source-app", "to target app", "target-app", "in org my-org / space space-name as my-user..."},
[]string{"Note: this may take some time"},
[]string{"OK"},
))
示例14:
app := models.ApplicationFields{}
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 = "whose-space-is-it-anyway"
space.Organization = org
space.Applications = apps
space.Domains = domains
space.ServiceInstances = services
requirementsFactory.LoginSuccess = true
requirementsFactory.TargetedOrgSuccess = true
requirementsFactory.Space = space
})
It("shows information about the given space", func() {
runCommand("whose-space-is-it-anyway")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Getting info for space", "whose-space-is-it-anyway", "my-org", "my-user"},
示例15:
orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
orgRepo.FindByNameReturns(org, nil)
})
It("it updates the organization in the config", func() {
callTarget([]string{"-o", "my-organization"})
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
})
It("updates the space in the config", func() {
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
spaceRepo.FindByNameReturns(space, nil)
callTarget([]string{"-s", "my-space"})
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("updates both the organization and the space in the config", func() {
space := models.Space{}
space.Name = "my-space"