当前位置: 首页>>代码示例>>Golang>>正文


Golang mocks.Server类代码示例

本文整理汇总了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
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:9,代码来源:helpers_test.go

示例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
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:13,代码来源:helpers_test.go

示例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
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:14,代码来源:helpers_test.go

示例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
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:15,代码来源:helpers_test.go

示例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
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:15,代码来源:helpers_test.go

示例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
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:19,代码来源:mocks_test.go

示例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"
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:32,代码来源:info_test.go

示例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"}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:31,代码来源:clusters_test.go

示例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
		}
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:32,代码来源:error_test.go

示例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()
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:30,代码来源:auth_test.go

示例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"},
		}
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:31,代码来源:hosts_test.go

示例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() {
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:31,代码来源:projects_test.go

示例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",
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:31,代码来源:vms_test.go

示例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()
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:31,代码来源:flavors_test.go

示例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,
			},
		}
开发者ID:cloudfoundry-incubator,项目名称:bosh-photon-cpi-release,代码行数:31,代码来源:deployments_test.go


注:本文中的github.com/vmware/photon-controller-go-sdk/photon/internal/mocks.Server类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。