本文整理汇总了Golang中github.com/vmware/photon-controller-go-sdk/photon/internal/mocks.Server类的典型用法代码示例。如果您正苦于以下问题:Golang Server类的具体用法?Golang Server怎么用?Golang Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createTenant
func createTenant(server *mocks.Server, client *Client) string {
mockTask := createMockTask("CREATE_TENANT", "COMPLETED")
server.SetResponseJson(200, mockTask)
tenantSpec := &TenantCreateSpec{Name: randomString(10, "go-sdk-tenant-")}
task, err := client.Tenants.Create(tenantSpec)
GinkgoT().Log(err)
Expect(err).Should(BeNil())
return task.Entity.ID
}
示例2: createResTicket
func createResTicket(server *mocks.Server, client *Client, tenantID string) string {
resTicketName := randomString(10)
spec := &ResourceTicketCreateSpec{
Name: resTicketName,
Limits: []QuotaLineItem{QuotaLineItem{Unit: "GB", Value: 16, Key: "vm.memory"}},
}
mockTask := createMockTask("CREATE_RESOURCE_TICKET", "COMPLETED")
server.SetResponseJson(200, mockTask)
_, err := client.Tenants.CreateResourceTicket(tenantID, spec)
GinkgoT().Log(err)
Expect(err).Should(BeNil())
return resTicketName
}
示例3: createImage
func createImage(server *mocks.Server, client *Client) string {
mockTask := createMockTask("CREATE_IMAGE", "COMPLETED", createMockStep("UPLOAD_IMAGE", "COMPLETED"))
server.SetResponseJson(200, mockTask)
// create image from file
imagePath := "../testdata/tty_tiny.ova"
task, err := client.Images.CreateFromFile(imagePath, &ImageCreateOptions{ReplicationType: "ON_DEMAND"})
task, err = client.Tasks.Wait(task.ID)
GinkgoT().Log(err)
Expect(err).Should(BeNil())
return task.Entity.ID
}
示例4: createFlavor
// Returns flavorName, flavorID
func createFlavor(server *mocks.Server, client *Client) (string, string) {
mockTask := createMockTask("CREATE_FLAVOR", "COMPLETED")
server.SetResponseJson(200, mockTask)
flavorName := randomString(10, "go-sdk-flavor-")
flavorSpec := &FlavorCreateSpec{
[]QuotaLineItem{QuotaLineItem{"COUNT", 1, "persistent-disk.cost"}},
"persistent-disk",
flavorName,
}
task, err := client.Flavors.Create(flavorSpec)
GinkgoT().Log(err)
Expect(err).Should(BeNil())
return flavorName, task.Entity.ID
}
示例5: createProject
func createProject(server *mocks.Server, client *Client, tenantID string, resName string) string {
mockTask := createMockTask("CREATE_PROJECT", "COMPLETED")
server.SetResponseJson(200, mockTask)
projSpec := &ProjectCreateSpec{
ResourceTicket: ResourceTicketReservation{
resName,
[]QuotaLineItem{QuotaLineItem{"GB", 2, "vm.memory"}},
},
Name: randomString(10, "go-sdk-project-"),
}
task, err := client.Tenants.CreateProject(tenantID, projSpec)
GinkgoT().Log(err)
Expect(err).Should(BeNil())
return task.Entity.ID
}
示例6: createMockAuthInfo
func createMockAuthInfo(server *mocks.Server) (mock *AuthInfo) {
mock = &AuthInfo{
Enabled: false,
}
if server == nil {
return
}
address, port, err := server.GetAddressAndPort()
if err != nil {
return
}
mock.Enabled = true
mock.Endpoint = address
mock.Port = port
return
}
示例7:
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = ginkgo.Describe("Info", func() {
var (
server *mocks.Server
client *Client
)
ginkgo.BeforeEach(func() {
server, client = testSetup()
})
ginkgo.AfterEach(func() {
server.Close()
})
ginkgo.Describe("Get", func() {
ginkgo.It("Get deployment info successfully", func() {
baseVersion := "1.1.0"
fullVersion := "1.1.0-bcea65f"
gitCommitHash := "bcea65f"
示例8:
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = Describe("Cluster", func() {
var (
server *mocks.Server
client *Client
kubernetesClusterSpec *ClusterCreateSpec
mesosClusterSpec *ClusterCreateSpec
tenantID string
resName string
projID string
)
BeforeEach(func() {
if isIntegrationTest() {
Skip("Skipping cluster test on integration mode. Need to set extendedProperties to use real IPs and masks")
}
server, client = testSetup()
tenantID = createTenant(server, client)
resName = createResTicket(server, client, tenantID)
projID = createProject(server, client, tenantID, resName)
kubernetesMap := map[string]string{"dns": "1.1.1.1", "gateway": "1.1.1.2", "netmask": "255.255.255.128",
"master_ip": "1.1.1.3", "container_network": "1.2.0.0/16"}
示例9:
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = Describe("ErrorTesting", func() {
var (
server *mocks.Server
client *Client
)
BeforeEach(func() {
server, client = testSetup()
})
AfterEach(func() {
server.Close()
})
It("TaskError", func() {
// Unit test only
if isIntegrationTest() {
return
}
示例10:
package photon
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
"github.com/vmware/photon-controller-go-sdk/photon/lightwave"
)
var _ = Describe("Auth", func() {
var (
server *mocks.Server
authServer *mocks.Server
client *Client
)
BeforeEach(func() {
if isIntegrationTest() {
Skip("Skipping auth test as we don't know if auth is on or off.")
}
server, client = testSetup()
authServer = mocks.NewTlsTestServer()
})
AfterEach(func() {
server.Close()
authServer.Close()
示例11:
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = Describe("Host", func() {
var (
server *mocks.Server
client *Client
hostSpec *HostCreateSpec
)
BeforeEach(func() {
if isIntegrationTest() {
Skip("Skipping Host test on integration mode. Unable to prevent address host collision")
}
server, client = testSetup()
hostSpec = &HostCreateSpec{
Username: randomString(10),
Password: randomString(10),
Address: randomAddress(),
Tags: []string{"CLOUD"},
Metadata: map[string]string{"Test": "go-sdk-host"},
}
示例12:
package photon
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = Describe("Project", func() {
var (
server *mocks.Server
client *Client
tenantID string
resName string
projID string
flavorName string
flavorID string
)
BeforeEach(func() {
server, client = testSetup()
tenantID = createTenant(server, client)
resName = createResTicket(server, client, tenantID)
projID = createProject(server, client, tenantID, resName)
flavorName, flavorID = createFlavor(server, client)
})
AfterEach(func() {
示例13:
package photon
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
"os"
)
var _ = Describe("VM", func() {
var (
server *mocks.Server
client *Client
tenantID string
resName string
projID string
imageID string
flavorSpec *FlavorCreateSpec
vmFlavorSpec *FlavorCreateSpec
vmSpec *VmCreateSpec
)
BeforeEach(func() {
server, client = testSetup()
tenantID = createTenant(server, client)
resName = createResTicket(server, client, tenantID)
projID = createProject(server, client, tenantID, resName)
imageID = createImage(server, client)
flavorSpec = &FlavorCreateSpec{
[]QuotaLineItem{QuotaLineItem{"COUNT", 1, "ephemeral-disk.cost"}},
"ephemeral-disk",
示例14:
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = Describe("Flavor", func() {
var (
server *mocks.Server
client *Client
flavorSpec *FlavorCreateSpec
)
BeforeEach(func() {
server, client = testSetup()
flavorSpec = &FlavorCreateSpec{
Name: randomString(10, "go-sdk-flavor-"),
Kind: "vm",
Cost: []QuotaLineItem{QuotaLineItem{"GB", 16, "vm.memory"}},
}
})
AfterEach(func() {
cleanFlavors(client)
server.Close()
示例15:
// of the subcomponent's license, as noted in the LICENSE file.
package photon
import (
"reflect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)
var _ = Describe("Deployment", func() {
var (
server *mocks.Server
client *Client
deploymentSpec *DeploymentCreateSpec
)
BeforeEach(func() {
if isIntegrationTest() {
Skip("Skipping deployment test on integration mode. Need undeployed environment")
}
server, client = testSetup()
deploymentSpec = &DeploymentCreateSpec{
ImageDatastores: []string{randomString(10, "go-sdk-deployment-")},
UseImageDatastoreForVms: true,
Auth: &AuthInfo{
Enabled: false,
},
}