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


Golang assert.Equal函数代码示例

本文整理汇总了Golang中github.com/alexsacr/linode/_third_party/testify/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestAvailDatacentersIntegration

func TestAvailDatacentersIntegration(t *testing.T) {
	c := NewClient(apiKey)

	datacenters, err := c.AvailDatacenters()
	require.NoError(t, err)
	require.NotEmpty(t, datacenters)

	// Test subset
	var foundDallas bool
	var foundFremont bool

	for _, dc := range datacenters {
		switch dc.ID {
		case 2:
			assert.Equal(t, "Dallas, TX, USA", dc.Location, "dc.Location")
			assert.Equal(t, "dallas", dc.Abbr, "dc.Abbr")
			foundDallas = true
		case 3:
			assert.Equal(t, "Fremont, CA, USA", dc.Location, "dc.Location")
			assert.Equal(t, "fremont", dc.Abbr, "dc.Abbr")
			foundFremont = true
		}
	}

	assert.True(t, foundDallas, "Dallas not returned.")
	assert.True(t, foundFremont, "Fremont not returned.")
}
开发者ID:alexsacr,项目名称:linode,代码行数:27,代码来源:integration_test.go

示例2: TestAvailKernelsOK

func TestAvailKernelsOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsOK()))
	defer ts.Close()

	kerns, err := c.AvailKernels(nil, nil)
	require.NoError(t, err)
	require.Len(t, kerns, 135)

	var sample Kernel
	var everXen bool
	var everPVOps bool

	for _, k := range kerns {
		if k.IsXen {
			everXen = true
		}
		if k.IsPVOps {
			everPVOps = true
		}
		assert.NotEmpty(t, k.Label, "k.Label")
		assert.NotEmpty(t, k.ID, "k.ID")

		if k.ID == 138 {
			sample = k
		}
	}
	assert.True(t, everXen, "everXen")
	assert.True(t, everPVOps, "everPVOps")

	assert.Equal(t, "Latest 64 bit (4.1.0-x86_64-linode59)", sample.Label, "sample.Label")
	assert.True(t, sample.IsXen, "sample.IsXen")
	assert.True(t, sample.IsPVOps, "sample.IsPVOps")
	assert.Equal(t, 138, sample.ID, "sample.ID")
}
开发者ID:alexsacr,项目名称:linode,代码行数:34,代码来源:api_utility_test.go

示例3: TestLinodeIPAddPrivateOK

func TestLinodeIPAddPrivateOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeIPAddPrivateOK()))
	defer ts.Close()

	id, addr, err := c.LinodeIPAddPrivate(1146420)
	require.NoError(t, err)
	assert.Equal(t, 374332, id)
	assert.Equal(t, "192.168.199.65", addr)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_linode_test.go

示例4: TestLinodeDiskDuplicateOK

func TestLinodeDiskDuplicateOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskDuplicateOK()))
	defer ts.Close()

	jobID, dupeDiskID, err := c.LinodeDiskDuplicate(1139016, 3569220)
	require.NoError(t, err)
	assert.Equal(t, 25090699, jobID)
	assert.Equal(t, 3569577, dupeDiskID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_linode_test.go

示例5: TestLinodeDiskCreateOK

func TestLinodeDiskCreateOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskCreateOK()))
	defer ts.Close()

	jobID, diskID, err := c.LinodeDiskCreate(1139016, "test-swap", "swap", 256)
	require.NoError(t, err)
	assert.Equal(t, 3568984, diskID)
	assert.Equal(t, 25087627, jobID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_linode_test.go

示例6: TestAccountEstimateInvoiceOK

func TestAccountEstimateInvoiceOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAccountEstimateInvoiceOK()))
	defer ts.Close()

	inv, err := c.AccountEstimateInvoice("linode_new", Int(1), Int(1), Int(1))
	require.NoError(t, err)
	assert.Equal(t, "2015-07-31 23:59:59", inv.InvoiceTo)
	assert.Equal(t, 8.07, inv.Price)
}
开发者ID:alexsacr,项目名称:linode,代码行数:9,代码来源:api_account_test.go

示例7: TestLinodeDiskCreateFromImageOK

func TestLinodeDiskCreateFromImageOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskCreateFromImageOK()))
	defer ts.Close()

	jobID, imgDiskID, err := c.LinodeDiskCreateFromImage(396235, 1139016, "test-image", Int(800),
		String(rootPass), String(rootSSHKey))
	require.NoError(t, err)
	assert.Equal(t, 25090431, jobID)
	assert.Equal(t, 3569532, imgDiskID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:10,代码来源:api_linode_test.go

示例8: TestLinodeDiskImagizeOK

func TestLinodeDiskImagizeOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskImagizeOK()))
	defer ts.Close()

	jobID, imgID, err := c.LinodeDiskImagize(1139016, 3569234, String("test-image desc"),
		String("test-image label"))

	require.NoError(t, err)
	assert.Equal(t, 25090408, jobID)
	assert.Equal(t, 396235, imgID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:11,代码来源:api_linode_test.go

示例9: TestAvailLinodePlansIntegration

func TestAvailLinodePlansIntegration(t *testing.T) {
	c := NewClient(apiKey)

	plans, err := c.AvailLinodePlans(nil)
	require.NoError(t, err)
	require.NotEmpty(t, plans)

	testPlanNotEmpty(t, plans)

	// Spot check
	plans, err = c.AvailLinodePlans(Int(1))
	require.NoError(t, err)
	require.Len(t, plans, 1)

	p := plans[0]

	assert.Equal(t, 1, p.Cores)
	assert.Equal(t, 10.00, p.Price)
	assert.Equal(t, 1024, p.RAM)
	assert.Equal(t, 2000, p.Xfer)
	assert.Equal(t, 1, p.ID)
	assert.Equal(t, "Linode 1024", p.Label)
	assert.Equal(t, 24, p.Disk)
	assert.Equal(t, 0.015, p.Hourly)

	plans, err = c.AvailLinodePlans(Int(3498230))
	require.NoError(t, err)
	require.Empty(t, plans)
}
开发者ID:alexsacr,项目名称:linode,代码行数:29,代码来源:integration_test.go

示例10: TestAvailKernelsSingle

func TestAvailKernelsSingle(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsSingle()))
	defer ts.Close()

	kerns, err := c.AvailKernels(Int(138), Bool(true))
	require.NoError(t, err)
	require.Len(t, kerns, 1)

	k := kerns[0]

	assert.Equal(t, "Latest 64 bit (4.1.0-x86_64-linode59)", k.Label, "k.Label")
	assert.True(t, k.IsXen, "k.IsXen")
	assert.True(t, k.IsPVOps, "k.IsPVOps")
	assert.Equal(t, 138, k.ID, "k.ID")
}
开发者ID:alexsacr,项目名称:linode,代码行数:15,代码来源:api_utility_test.go

示例11: TestLinodeIPListOK

func TestLinodeIPListOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeIPListOK()))
	defer ts.Close()

	IPList, err := c.LinodeIPList(Int(1146420), Int(1))
	require.NoError(t, err)
	require.Len(t, IPList, 1)

	IP := IPList[0]
	assert.Equal(t, 296963, IP.ID)
	assert.Equal(t, "li959-147.members.linode.com", IP.RDNSName)
	assert.Equal(t, 1146420, IP.LinodeID)
	assert.True(t, IP.IsPublic)
	assert.Equal(t, "45.33.5.147", IP.Address)
}
开发者ID:alexsacr,项目名称:linode,代码行数:15,代码来源:api_linode_test.go

示例12: newMockAPIServer

func newMockAPIServer(t *testing.T, responses []mockAPIResponse) *httptest.Server {
	var reqCount int

	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if len(responses) < reqCount {
			msg := fmt.Sprintf("Request count: %d len(responses): %d", reqCount+1, len(responses))
			require.FailNow(t, msg)
		}

		resp := responses[reqCount]

		action := r.FormValue("api_action")
		require.NotEmpty(t, action, fmt.Sprintf("%d", reqCount+1))

		require.Equal(t, resp.action, action, fmt.Sprintf("%d", reqCount+1))

		for k, v := range resp.params {
			assert.Equal(t, v, r.FormValue(k), fmt.Sprintf("params: %s - %d", k, reqCount+1))
		}

		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(200)
		_, _ = w.Write([]byte(resp.output()))

		reqCount++
	}))

	return ts
}
开发者ID:alexsacr,项目名称:linode,代码行数:29,代码来源:mocks_test.go

示例13: TestAvailDatacentersOK

func TestAvailDatacentersOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockAvailDatacentersOK()))
	defer ts.Close()

	datacenters, err := c.AvailDatacenters()
	require.NoError(t, err)
	require.NotEmpty(t, datacenters)

	expected := []Datacenter{
		{
			Location: "Dallas, TX, USA",
			ID:       2,
			Abbr:     "dallas",
		},
		{
			Location: "Fremont, CA, USA",
			ID:       3,
			Abbr:     "fremont",
		},
		{
			Location: "Atlanta, GA, USA",
			ID:       4,
			Abbr:     "atlanta",
		},
		{
			Location: "Newark, NJ, USA",
			ID:       6,
			Abbr:     "newark",
		},
		{
			Location: "London, England, UK",
			ID:       7,
			Abbr:     "london",
		},
		{
			Location: "Tokyo, JP",
			ID:       8,
			Abbr:     "tokyo",
		},
		{
			Location: "Singapore, SG",
			ID:       9,
			Abbr:     "singapore",
		},
	}

	for i, eDC := range expected {
		for _, aDC := range datacenters {
			if reflect.DeepEqual(aDC, eDC) {
				expected[i] = Datacenter{}
				break
			}
		}
	}

	for _, dc := range expected {
		assert.Equal(t, Datacenter{}, dc, fmt.Sprintf("%+v not returned.", dc))
	}
}
开发者ID:alexsacr,项目名称:linode,代码行数:59,代码来源:api_utility_test.go

示例14: TestLinodeShutdownOK

func TestLinodeShutdownOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeShutdownOK()))
	defer ts.Close()

	jobID, err := c.LinodeShutdown(1146420)
	require.NoError(t, err)
	assert.Equal(t, 25167147, jobID)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_linode_test.go

示例15: TestLinodeRebootOK

func TestLinodeRebootOK(t *testing.T) {
	c, ts := clientFor(newMockAPIServer(t, mockLinodeRebootOK()))
	defer ts.Close()

	jobID, err := c.LinodeReboot(1146420, Int(1862370))
	require.NoError(t, err)
	assert.Equal(t, jobID, 25167140)
}
开发者ID:alexsacr,项目名称:linode,代码行数:8,代码来源:api_linode_test.go


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