本文整理汇总了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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
})
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
})
}
示例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)
}
示例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)
}