當前位置: 首頁>>代碼示例>>Golang>>正文


Golang tests.Run函數代碼示例

本文整理匯總了Golang中github.com/codedellemc/libstorage/api/tests.Run函數的典型用法代碼示例。如果您正苦於以下問題:Golang Run函數的具體用法?Golang Run怎麽用?Golang Run使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Run函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestVolumeAttach

func TestVolumeAttach(t *testing.T) {
	tf := func(config gofig.Config, client types.Client, t *testing.T) {

		nextDevice, err := client.Executor().NextDevice(
			context.Background().WithValue(context.ServiceKey, vfs.Name),
			utils.NewStore())
		assert.NoError(t, err)
		if err != nil {
			t.FailNow()
		}

		request := &types.VolumeAttachRequest{
			NextDeviceName: &nextDevice,
		}

		reply, attTokn, err := client.API().VolumeAttach(
			nil, vfs.Name, "vfs-002", request)
		assert.NoError(t, err)
		if reply == nil {
			t.FailNow()
		}
		assert.Equal(t, "/dev/xvdc", attTokn)
		assert.Equal(t, "vfs-002", reply.ID)
		assert.Equal(t, "/dev/xvdc", reply.Attachments[0].DeviceName)

	}
	apitests.Run(t, vfs.Name, newTestConfig(t), tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:28,代碼來源:vfs_test.go

示例2: TestVolumeDetachAll

func TestVolumeDetachAll(t *testing.T) {
	tc, _, vols, _ := newTestConfigAll(t)
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		request := &types.VolumeDetachRequest{}
		reply, err := client.API().VolumeDetachAll(
			nil, request)
		assert.NoError(t, err)
		for _, v := range vols {
			v.Attachments = nil
		}
		assert.Equal(t, 1, len(reply))
		assert.Equal(t, 3, len(reply[vfs.Name]))
		assert.EqualValues(t, vols, reply[vfs.Name])

		reply, err = client.API().Volumes(nil, types.VolAttReqTrue)
		assert.NoError(t, err)
		assert.Equal(t, 1, len(reply))
		assert.Equal(t, 0, len(reply[vfs.Name]))

		reply, err = client.API().Volumes(nil, 0)
		assert.NoError(t, err)
		assert.Equal(t, 1, len(reply))
		assert.Equal(t, 3, len(reply[vfs.Name]))
	}
	apitests.Run(t, vfs.Name, tc, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:26,代碼來源:vfs_test.go

示例3: TestSnapshotCopy

func TestSnapshotCopy(t *testing.T) {
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		snapshotName := "Snapshot from vfs-000-000"

		opts := map[string]interface{}{
			"priority": 2,
			"owner":    "[email protected]",
		}

		request := &types.SnapshotCopyRequest{
			SnapshotName: snapshotName,
			Opts:         opts,
		}

		reply, err := client.API().SnapshotCopy(
			nil, vfs.Name, "vfs-000-000", request)
		assert.NoError(t, err)
		apitests.LogAsJSON(reply, t)

		assert.Equal(t, snapshotName, reply.Name)
		assert.Equal(t, "vfs-000", reply.VolumeID)
		assert.Equal(t, "2", reply.Fields["priority"])
		assert.Equal(t, "[email protected]", reply.Fields["owner"])

	}
	apitests.Run(t, vfs.Name, newTestConfig(t), tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:27,代碼來源:vfs_test.go

示例4: TestVolumeCopy

func TestVolumeCopy(t *testing.T) {
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		request := &types.VolumeCopyRequest{
			VolumeName: "Copy of Volume 000",
			Opts: map[string]interface{}{
				"priority": 7,
				"owner":    "[email protected]",
			},
		}

		reply, err := client.API().VolumeCopy(nil, vfs.Name, "vfs-000", request)
		assert.NoError(t, err)
		if err != nil {
			t.FailNow()
		}

		assert.NotNil(t, reply)

		assertVolDir(t, config, reply.ID, true)
		assert.Equal(t, "vfs-003", reply.ID)
		assert.Equal(t, request.VolumeName, reply.Name)
		assert.Equal(t, "7", reply.Fields["priority"])
		assert.Equal(t, request.Opts["owner"], reply.Fields["owner"])
	}

	apitests.Run(t, vfs.Name, newTestConfig(t), tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:27,代碼來源:vfs_test.go

示例5: TestConfig

///////////////////////////////////////////////////////////////////////
/////////                    PUBLIC TESTS                     /////////
///////////////////////////////////////////////////////////////////////
// Test if backwards compatibility for "ec2" and "ebs" work in config
func TestConfig(t *testing.T) {
	if skipTests() {
		t.SkipNow()
	}
	tfEBS := func(config gofig.Config, client types.Client, t *testing.T) {
		assert.NotEqual(t, config.GetString("ebs.tag"), "")
		assert.Equal(t, config.GetString("ec2.tag"), "")
	}
	tfEC2 := func(config gofig.Config, client types.Client, t *testing.T) {
		assert.NotEqual(t, config.GetString("ec2.tag"), "")
		assert.Equal(t, config.GetString("ebs.tag"), "")
	}
	apitests.Run(t, "ec2", configYAMLebs, tfEBS)
	apitests.Run(t, "ec2", configYAMLec2, tfEC2)
	apitests.Run(t, ebs.Name, configYAMLebs, tfEBS)
	apitests.Run(t, ebs.Name, configYAMLec2, tfEC2)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:21,代碼來源:ebs_test.go

示例6: TestVolumeCreateRemove

func TestVolumeCreateRemove(t *testing.T) { //PASSES lowercase hidden for testing other stuff
	if skipTests() {
		t.SkipNow()
	}
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		vol := volumeCreate(t, client, volumeName)
		volumeRemove(t, client, vol.ID)
	}
	apitests.Run(t, rackspace.Name, configYAML, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:10,代碼來源:rackspace_test.go

示例7: TestServiceInpspect

func TestServiceInpspect(t *testing.T) {
	tf := func(config gofig.Config, client types.Client, t *testing.T) {

		reply, err := client.API().ServiceInspect(nil, vfs.Name)
		assert.NoError(t, err)
		assert.Equal(t, vfs.Name, reply.Name)
		assert.Equal(t, vfs.Name, reply.Driver.Name)
		assert.True(t, reply.Driver.NextDevice.Ignore)
	}
	apitests.Run(t, vfs.Name, newTestConfig(t), tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:11,代碼來源:vfs_test.go

示例8: TestClient

func TestClient(t *testing.T) {
	apitests.Run(t, vfs.Name, newTestConfig(t),
		func(config gofig.Config, client types.Client, t *testing.T) {
			ctx := context.Background()
			iid, err := client.Executor().InstanceID(
				ctx.WithValue(context.ServiceKey, vfs.Name),
				utils.NewStore())
			assert.NoError(t, err)
			assert.NotNil(t, iid)
		})
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:11,代碼來源:vfs_test.go

示例9: TestVolumeCreateRemove

func TestVolumeCreateRemove(t *testing.T) {
	if skipTests() {
		t.SkipNow()
	}

	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		vol := volumeCreate(t, client, volumeName)
		volumeRemove(t, client, vol.ID)
	}
	apitests.Run(t, sio.Name, configYAML, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:11,代碼來源:scaleio_test.go

示例10: TestEncryptedVolumeCreateRemove

// Test volume functionality from storage driver
func TestEncryptedVolumeCreateRemove(t *testing.T) {
	if skipTests() {
		t.SkipNow()
	}

	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		vol := volumeCreateEncrypted(t, client, volumeName, config.GetString("ec2.tag"))
		volumeRemove(t, client, vol.ID)
	}
	//apitests.Run(t, ebs.Name, configYAMLec2, tf)
	apitests.Run(t, "ebs", configYAMLec2, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:13,代碼來源:ebs_test.go

示例11: TestInstanceID

func TestInstanceID(t *testing.T) {
	iid, err := instanceID()
	assert.NoError(t, err)
	if err != nil {
		t.FailNow()
	}
	apitests.Run(
		t, vfs.Name, newTestConfig(t),
		(&apitests.InstanceIDTest{
			Driver:   vfs.Name,
			Expected: iid,
		}).Test)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:13,代碼來源:vfs_test.go

示例12: TestVolumeInspectWithAttachments

func TestVolumeInspectWithAttachments(t *testing.T) {
	tc, _, vols, _ := newTestConfigAll(t)
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		reply, err := client.API().VolumeInspect(
			nil, "vfs", "vfs-000", types.VolAttReqTrue)
		if err != nil {
			t.Fatal(err)
		}
		assert.NotNil(t, reply)
		assert.EqualValues(t, vols[reply.ID], reply)
	}
	apitests.Run(t, vfs.Name, tc, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:13,代碼來源:vfs_test.go

示例13: TestStorageDriverVolumes

func TestStorageDriverVolumes(t *testing.T) {
	apitests.Run(t, vfs.Name, newTestConfig(t),
		func(config gofig.Config, client types.Client, t *testing.T) {

			vols, err := client.Storage().Volumes(
				context.Background().WithValue(
					context.ServiceKey, vfs.Name),
				&types.VolumesOpts{
					Attachments: types.VolAttReqTrue,
					Opts:        utils.NewStore()})
			assert.NoError(t, err)
			assert.Len(t, vols, 2)
		})
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:14,代碼來源:vfs_test.go

示例14: TestSnapshotsByService

func TestSnapshotsByService(t *testing.T) {
	tc, _, _, snaps := newTestConfigAll(t)
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		reply, err := client.API().SnapshotsByService(nil, "vfs")
		if err != nil {
			t.Fatal(err)
		}
		for snapshotID, snapshot := range snaps {
			assert.NotNil(t, reply[snapshotID])
			assert.EqualValues(t, snapshot, reply[snapshotID])
		}
	}
	apitests.Run(t, vfs.Name, tc, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:14,代碼來源:vfs_test.go

示例15: TestServices

func TestServices(t *testing.T) { //PASSES lowercase hidden for testing other stuff
	if skipTests() {
		t.SkipNow()
	}

	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		reply, err := client.API().Services(nil)
		assert.NoError(t, err)
		assert.Equal(t, len(reply), 1)

		_, ok := reply[rackspace.Name]
		assert.True(t, ok)
	}
	apitests.Run(t, rackspace.Name, configYAML, tf)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:15,代碼來源:rackspace_test.go


注:本文中的github.com/codedellemc/libstorage/api/tests.Run函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。