本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/models.ServiceOffering类的典型用法代码示例。如果您正苦于以下问题:Golang ServiceOffering类的具体用法?Golang ServiceOffering怎么用?Golang ServiceOffering使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceOffering类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ToModel
func (resource ServiceOfferingResource) ToModel() models.ServiceOffering {
offering := models.ServiceOffering{
ServiceOfferingFields: resource.ToFields(),
}
for _, p := range resource.Entity.ServicePlans {
offering.Plans = append(offering.Plans,
models.ServicePlanFields{
Name: p.Entity.Name,
Guid: p.Metadata.Guid,
},
)
}
return offering
}
开发者ID:datatonic,项目名称:cli,代码行数:16,代码来源:service_offerings.go
示例2: attachPlansToService
func (builder Builder) attachPlansToService(service models.ServiceOffering) (models.ServiceOffering, error) {
plans, err := builder.planBuilder.GetPlansForService(service.Guid)
if err != nil {
return models.ServiceOffering{}, err
}
service.Plans = plans
return service, nil
}
开发者ID:Jack1996,项目名称:cli,代码行数:9,代码来源:service_builder.go
示例3:
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/cli/cf/commands/service"
"github.com/cloudfoundry/cli/cf/flags"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("update-service command", func() {
var (
ui *testterm.FakeUI
config coreconfig.Repository
requirementsFactory *requirementsfakes.FakeFactory
serviceRepo *apifakes.FakeServiceRepository
planBuilder *planbuilderfakes.FakePlanBuilder
offering1 models.ServiceOffering
deps commandregistry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.Config = config
deps.PlanBuilder = planBuilder
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("update-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
开发者ID:jasonkeene,项目名称:cli,代码行数:31,代码来源:update_service_test.go
示例4:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("create-service command", func() {
var (
ui *testterm.FakeUI
config configuration.Repository
requirementsFactory *testreq.FakeReqFactory
cmd CreateService
serviceRepo *testapi.FakeServiceRepo
offering1 models.ServiceOffering
offering2 models.ServiceOffering
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
serviceRepo = &testapi.FakeServiceRepo{}
cmd = NewCreateService(ui, config, serviceRepo)
offering1 = models.ServiceOffering{}
offering1.Label = "cleardb"
offering1.Plans = []models.ServicePlanFields{{
开发者ID:hail100,项目名称:cli,代码行数:32,代码来源:create_service_test.go
示例5:
})
})
})
Describe("PurgeServiceOffering", func() {
It("purges service offerings", func() {
setupTestServer(testnet.TestRequest{
Method: "DELETE",
Path: "/v2/services/the-service-guid?purge=true",
Response: testnet.TestResponse{
Status: 204,
}})
offering := models.ServiceOffering{ServiceOfferingFields: models.ServiceOfferingFields{
Label: "the-offering",
GUID: "the-service-guid",
Description: "some service description",
}}
offering.GUID = "the-service-guid"
err := repo.PurgeServiceOffering(offering)
Expect(err).NotTo(HaveOccurred())
Expect(testHandler).To(HaveAllRequestsCalled())
})
})
Describe("PurgeServiceInstance", func() {
It("purges service instances", func() {
setupTestServer(testnet.TestRequest{
Method: "DELETE",
Path: "/v2/service_instances/instance-guid?purge=true",
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:services_test.go
示例6:
"github.com/cloudfoundry/cli/cf/commandregistry"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("create-service command", func() {
var (
ui *testterm.FakeUI
config coreconfig.Repository
requirementsFactory *requirementsfakes.FakeFactory
serviceRepo *apifakes.FakeServiceRepository
serviceBuilder *servicebuilderfakes.FakeServiceBuilder
offering1 models.ServiceOffering
offering2 models.ServiceOffering
deps commandregistry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = config
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.ServiceBuilder = serviceBuilder
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
开发者ID:Reejoshi,项目名称:cli,代码行数:30,代码来源:create_service_test.go
示例7:
Expect(err).NotTo(HaveOccurred())
cmd.Requirements(factory, flagContext)
})
It("tries to find the service offering by label", func() {
ui.Inputs = []string{"n"}
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{{}}, nil)
cmd.Execute(flagContext)
Expect(serviceRepo.FindServiceOfferingsByLabelCallCount()).To(Equal(1))
name := serviceRepo.FindServiceOfferingsByLabelArgsForCall(0)
Expect(name).To(Equal("service-name"))
})
Context("when finding the service offering succeeds", func() {
BeforeEach(func() {
serviceOffering := models.ServiceOffering{}
serviceOffering.GUID = "service-offering-guid"
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{serviceOffering}, nil)
})
It("asks the user to confirm", func() {
ui.Inputs = []string{"n"}
cmd.Execute(flagContext)
Expect(ui.Outputs).To(ContainSubstrings([]string{"WARNING"}))
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really purge service offering service-name from Cloud Foundry?"}))
})
Context("when the user confirms", func() {
BeforeEach(func() {
ui.Inputs = []string{"y"}
})
开发者ID:yingkitw,项目名称:cli,代码行数:31,代码来源:purge_service_offering_test.go
示例8:
_, err = cmd.Requirements(factory, flagContext)
Expect(err).NotTo(HaveOccurred())
})
It("tries to find the service offering by label", func() {
ui.Inputs = []string{"n"}
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{{}}, nil)
cmd.Execute(flagContext)
Expect(serviceRepo.FindServiceOfferingsByLabelCallCount()).To(Equal(1))
name := serviceRepo.FindServiceOfferingsByLabelArgsForCall(0)
Expect(name).To(Equal("service-name"))
})
Context("when finding the service offering succeeds", func() {
BeforeEach(func() {
serviceOffering := models.ServiceOffering{}
serviceOffering.Guid = "service-offering-guid"
serviceRepo.FindServiceOfferingsByLabelReturns([]models.ServiceOffering{serviceOffering}, nil)
})
It("asks the user to confirm", func() {
ui.Inputs = []string{"n"}
cmd.Execute(flagContext)
Expect(ui.Outputs).To(ContainSubstrings([]string{"WARNING"}))
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really purge service offering service-name from Cloud Foundry?"}))
})
Context("when the user confirms", func() {
BeforeEach(func() {
ui.Inputs = []string{"y"}
})
开发者ID:jmcabandara,项目名称:cli,代码行数:31,代码来源:purge_service_offering_test.go
注:本文中的github.com/cloudfoundry/cli/cf/models.ServiceOffering类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论