本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/models.SpaceFields类的典型用法代码示例。如果您正苦于以下问题:Golang SpaceFields类的具体用法?Golang SpaceFields怎么用?Golang SpaceFields使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpaceFields类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createAppInstancesRepo
func createAppInstancesRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo AppInstancesRepository) {
ts, handler = testnet.NewServer(requests)
space := models.SpaceFields{}
space.Guid = "my-space-guid"
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now)
repo = NewCloudControllerAppInstancesRepository(configRepo, gateway)
return
}
示例2: createAppInstancesRepo
func createAppInstancesRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo Repository) {
ts, handler = testnet.NewServer(requests)
space := models.SpaceFields{}
space.GUID = "my-space-guid"
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewCloudControllerAppInstancesRepository(configRepo, gateway)
return
}
示例3: callShowOrg
func callShowOrg(args []string, requirementsFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
token := core_config.TokenInfo{Username: "my-user"}
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo := testconfig.NewRepositoryWithAccessToken(token)
configRepo.SetSpaceFields(spaceFields)
configRepo.SetOrganizationFields(orgFields)
return
}
示例4: callListDomains
func callListDomains(args []string, requirementsFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo.SetSpaceFields(spaceFields)
configRepo.SetOrganizationFields(orgFields)
cmd := domain.NewListDomains(fakeUI, configRepo, domainRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
示例5: callDeleteSharedDomain
func callDeleteSharedDomain(args []string, inputs []string, deps deleteSharedDomainDependencies) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{
Inputs: inputs,
}
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo.SetSpaceFields(spaceFields)
configRepo.SetOrganizationFields(orgFields)
cmd := domain.NewDeleteSharedDomain(ui, configRepo, deps.domainRepo)
testcmd.RunCommand(cmd, args, deps.requirementsFactory)
return
}
示例6: callCreateOrg
func callCreateOrg(args []string, requirementsFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
space := models.SpaceFields{}
space.Name = "my-space"
organization := models.OrganizationFields{}
organization.Name = "my-org"
token := configuration.TokenInfo{Username: "my-user"}
config := testconfig.NewRepositoryWithAccessToken(token)
config.SetSpaceFields(space)
config.SetOrganizationFields(organization)
cmd := NewCreateOrg(fakeUI, config, orgRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
示例7:
"github.com/cloudfoundry/cli/cf/commands"
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/models"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("logout command", func() {
var config configuration.Repository
BeforeEach(func() {
org := models.OrganizationFields{}
org.Name = "MyOrg"
space := models.SpaceFields{}
space.Name = "MySpace"
config = testconfig.NewRepository()
config.SetAccessToken("MyAccessToken")
config.SetOrganizationFields(org)
config.SetSpaceFields(space)
ui := new(testterm.FakeUI)
l := commands.NewLogout(ui, config)
l.Run(nil)
})
It("clears access token from the config", func() {
Expect(config.AccessToken()).To(Equal(""))
})
示例8:
config.SetOrganizationFields(org.OrganizationFields)
runCommand("org-to-delete")
Expect(config.OrganizationFields()).To(Equal(models.OrganizationFields{}))
Expect(config.SpaceFields()).To(Equal(models.SpaceFields{}))
})
})
Context("when deleting an org that is not targeted", func() {
BeforeEach(func() {
otherOrgFields := models.OrganizationFields{}
otherOrgFields.Guid = "some-other-org-guid"
otherOrgFields.Name = "some-other-org"
config.SetOrganizationFields(otherOrgFields)
spaceFields := models.SpaceFields{}
spaceFields.Name = "some-other-space"
config.SetSpaceFields(spaceFields)
})
It("deletes the org with the given name", func() {
runCommand("org-to-delete")
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the org org-to-delete"}))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Deleting", "org-to-delete"},
[]string{"OK"},
))
Expect(orgRepo.DeleteArgsForCall(0)).To(Equal("org-to-delete-guid"))
示例9:
Expect(output).To(ContainSubstrings([]string{"Space:", "my-space"}))
})
})
})
It("prompts the user to target an org and space when no org or space is targeted", func() {
output := io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger)
ui.ShowConfiguration(config)
})
Expect(output).To(ContainSubstrings([]string{"No", "org", "space", "targeted", "-o ORG", "-s SPACE"}))
})
It("prompts the user to target an org when no org is targeted", func() {
sf := models.SpaceFields{}
sf.GUID = "guid"
sf.Name = "name"
output := io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger)
ui.ShowConfiguration(config)
})
Expect(output).To(ContainSubstrings([]string{"No", "org", "targeted", "-o ORG"}))
})
It("prompts the user to target a space when no space is targeted", func() {
of := models.OrganizationFields{}
of.GUID = "of-guid"
of.Name = "of-name"
示例10:
testServer = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testServerFn(w, r)
}))
gateway = net.NewCloudControllerGateway((config), time.Now, &testterm.FakeUI{})
gateway.SetTrustedCerts(testServer.TLS.Certificates)
repo = NewEndpointRepository(config, gateway)
})
AfterEach(func() {
testServer.Close()
})
Describe("updating the endpoints", func() {
Context("when the API request is successful", func() {
var (
org models.OrganizationFields
space models.SpaceFields
)
BeforeEach(func() {
org.Name = "my-org"
org.Guid = "my-org-guid"
space.Name = "my-space"
space.Guid = "my-space-guid"
config.SetOrganizationFields(org)
config.SetSpaceFields(space)
testServerFn = validApiInfoEndpoint
})
It("stores the data from the /info api in the config", func() {
repo.UpdateEndpoint(testServer.URL)
示例11:
org := models.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
requirementsFactory := &testreq.FakeReqFactory{Organization: org, LoginSuccess: true}
args := []string{"my-org"}
ui := callShowOrg(args, requirementsFactory)
Expect(ui.FailedWithUsage).To(BeFalse())
args = []string{}
ui = callShowOrg(args, requirementsFactory)
Expect(ui.FailedWithUsage).To(BeTrue())
})
It("TestRunWhenOrganizationExists", func() {
developmentSpaceFields := models.SpaceFields{}
developmentSpaceFields.Name = "development"
stagingSpaceFields := models.SpaceFields{}
stagingSpaceFields.Name = "staging"
domainFields := models.DomainFields{}
domainFields.Name = "cfapps.io"
cfAppDomainFields := models.DomainFields{}
cfAppDomainFields.Name = "cf-app.com"
org := models.Organization{}
org.Name = "my-org"
org.Guid = "my-org-guid"
org.QuotaDefinition = models.NewQuotaFields("cantina-quota", 512, 2, 5, true)
org.Spaces = []models.SpaceFields{developmentSpaceFields, stagingSpaceFields}
org.Domains = []models.DomainFields{domainFields, cfAppDomainFields}
requirementsFactory := &testreq.FakeReqFactory{Organization: org, LoginSuccess: true}
示例12:
Expect(output).To(ContainSubstrings([]string{"Space:", "my-space"}))
})
})
})
It("prompts the user to target an org and space when no org or space is targeted", func() {
output := io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, NewTeePrinter())
ui.ShowConfiguration(config)
})
Expect(output).To(ContainSubstrings([]string{"No", "org", "space", "targeted", "-o ORG", "-s SPACE"}))
})
It("prompts the user to target an org when no org is targeted", func() {
sf := models.SpaceFields{}
sf.Guid = "guid"
sf.Name = "name"
output := io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, NewTeePrinter())
ui.ShowConfiguration(config)
})
Expect(output).To(ContainSubstrings([]string{"No", "org", "targeted", "-o ORG"}))
})
It("prompts the user to target a space when no space is targeted", func() {
of := models.OrganizationFields{}
of.Guid = "of-guid"
of.Name = "of-name"
示例13:
It("fails when not logged in", func() {
Expect(runCommand("whoops")).To(BeFalse())
})
It("fails with usage when not provided exactly one arg", func() {
requirementsFactory.LoginSuccess = true
runCommand("too", "much")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
})
Context("when logged in, and provided the name of an org", func() {
BeforeEach(func() {
developmentSpaceFields := models.SpaceFields{}
developmentSpaceFields.Name = "development"
developmentSpaceFields.Guid = "dev-space-guid-1"
stagingSpaceFields := models.SpaceFields{}
stagingSpaceFields.Name = "staging"
stagingSpaceFields.Guid = "staging-space-guid-1"
domainFields := models.DomainFields{}
domainFields.Name = "cfapps.io"
domainFields.Guid = "1111"
domainFields.OwningOrganizationGuid = "my-org-guid"
domainFields.Shared = true
cfAppDomainFields := models.DomainFields{}
cfAppDomainFields.Name = "cf-app.com"
cfAppDomainFields.Guid = "2222"
cfAppDomainFields.OwningOrganizationGuid = "my-org-guid"
cfAppDomainFields.Shared = false
示例14:
testServer = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testServerFn(w, r)
}))
gateway = cloudcontrollergateway.NewTestCloudControllerGateway(coreConfig)
gateway.SetTrustedCerts(testServer.TLS.Certificates)
repo = NewEndpointRepository(gateway)
})
AfterEach(func() {
testServer.Close()
})
Describe("updating the endpoints", func() {
Context("when the API request is successful", func() {
var (
org models.OrganizationFields
space models.SpaceFields
)
BeforeEach(func() {
org.Name = "my-org"
org.GUID = "my-org-guid"
space.Name = "my-space"
space.GUID = "my-space-guid"
coreConfig.SetOrganizationFields(org)
coreConfig.SetSpaceFields(space)
testServerFn = validAPIInfoEndpoint
})
It("returns the configuration info from /info", func() {
config, endpoint, err := repo.GetCCInfo(testServer.URL)