• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang mocks.Server类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vmware/photon-controller-go-sdk/photon/internal/mocks.Server的典型用法代码示例。如果您正苦于以下问题:Golang Server类的具体用法?Golang Server怎么用?Golang Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Server类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16:

// 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 (
	"fmt"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)

var _ = Describe("Tenant", func() {
	var (
		server *mocks.Server
		client *Client
	)

	BeforeEach(func() {
		server, client = testSetup()
	})

	AfterEach(func() {
		cleanTenants(client)
		server.Close()
	})

	Describe("CreateAndDeleteTenant", func() {
		It("Tenant create and delete succeeds", func() {
			mockTask := createMockTask("CREATE_TENANT", "COMPLETED")
			server.SetResponseJson(200, mockTask)
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:32,代码来源:tenants_test.go


示例17:

// 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("VirtualSubnet", func() {
	var (
		server      *mocks.Server
		client      *Client
		networkSpec *VirtualSubnetCreateSpec
	)

	var projectId = "project1"

	ginkgo.BeforeEach(func() {
		server, client = testSetup()
		networkSpec = &VirtualSubnetCreateSpec{
			Name:                 randomString(10, "go-sdk-virtual-network-"),
			Description:          "a test virtual network",
			RoutingType:          "ROUTED",
			Size:                 256,
			ReservedStaticIpSize: 20,
		}
	})
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:31,代码来源:virtualnetworks_test.go


示例18:

// 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("ResourceTicket", func() {
	var (
		server   *mocks.Server
		client   *Client
		tenantID string
	)

	BeforeEach(func() {
		server, client = testSetup()
		tenantID = createTenant(server, client)
	})

	AfterEach(func() {
		cleanTenants(client)
		server.Close()
	})

	Describe("GetResourceTicketTasks", func() {
		It("GetTasks returns a completed task", func() {
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:31,代码来源:resourcetickets_test.go


示例19:

// 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 (
	"os"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)

var _ = Describe("Image", func() {
	var (
		server *mocks.Server
		client *Client
	)

	BeforeEach(func() {
		server, client = testSetup()
	})

	AfterEach(func() {
		cleanImages(client)
		server.Close()
	})

	Describe("CreateAndDeleteImage", func() {
		It("Image create from file and delete succeeds", func() {
			mockTask := createMockTask("CREATE_IMAGE", "COMPLETED", createMockStep("UPLOAD_IMAGE", "COMPLETED"))
			server.SetResponseJson(200, mockTask)
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:32,代码来源:images_test.go


示例20:

	"crypto/rand"
	"crypto/rsa"
	"crypto/x509"
	"crypto/x509/pkix"
	"encoding/pem"
	"math/big"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/vmware/photon-controller-go-sdk/photon/internal/mocks"
)

var _ = Describe("OIDCClient", func() {
	var (
		client *OIDCClient
		server *mocks.Server
	)

	AfterEach(func() {
		if server != nil {
			server.Close()
			server = nil
		}
	})

	Describe("NewOIDCClient", func() {
		It("Trims trailing '/' from endpoint", func() {
			endpointList := []string{
				"http://10.146.1.0/",
				"http://10.146.1.0",
			}
开发者ID:vmware,项目名称:photon-controller-go-sdk,代码行数:32,代码来源:oidcclient_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang rest.Post函数代码示例发布时间:2022-05-28
下一篇:
Golang photon.NewTestClient函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap