-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockstorage_volume_v3_test.go
More file actions
63 lines (54 loc) · 1.96 KB
/
Copy pathblockstorage_volume_v3_test.go
File metadata and controls
63 lines (54 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package openstack
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes"
)
func blockStorageVolumeV3VolumeFixture() volumes.Volume {
return volumes.Volume{
ID: "289da7f8-6440-407c-9fb4-7db01ec49164",
Name: "vol-001",
Attachments: []volumes.Attachment{{
ServerID: "83ec2e3b-4321-422b-8706-a84185f52a0a",
AttachmentID: "05551600-a936-4d4a-ba42-79a037c1-c91a",
AttachedAt: time.Date(2016, 8, 6, 14, 48, 20, 0, time.UTC),
HostName: "foobar",
VolumeID: "d6cacb1a-8b59-4c88-ad90-d70ebb82bb75",
Device: "/dev/vdc",
ID: "d6cacb1a-8b59-4c88-ad90-d70ebb82bb75",
}},
AvailabilityZone: "nova",
Bootable: "false",
ConsistencyGroupID: "",
CreatedAt: time.Date(2015, 9, 17, 3, 35, 3, 0, time.UTC),
Description: "",
Encrypted: false,
Metadata: map[string]string{"foo": "bar"},
Multiattach: false,
ReplicationStatus: "disabled",
Size: 75,
SnapshotID: "",
SourceVolID: "",
Status: "available",
UserID: "ff1ce52c03ab433aaba9108c2e3ef541",
VolumeType: "lvmdriver-1",
}
}
func TestFlattenBlockStorageVolumeV3Attachments(t *testing.T) {
expectedAttachments := []map[string]interface{}{
{
"id": "d6cacb1a-8b59-4c88-ad90-d70ebb82bb75",
"instance_id": "83ec2e3b-4321-422b-8706-a84185f52a0a",
"device": "/dev/vdc",
},
}
actualAttachments := flattenBlockStorageVolumeV3Attachments(blockStorageVolumeV3VolumeFixture().Attachments)
assert.Equal(t, expectedAttachments, actualAttachments)
}
func TestBlockStorageVolumeV3AttachmentHash(t *testing.T) {
attachments := flattenBlockStorageVolumeV3Attachments(blockStorageVolumeV3VolumeFixture().Attachments)
expectedHashcode := 236219624
actualHashcode := blockStorageVolumeV3AttachmentHash(attachments[0])
assert.Equal(t, expectedHashcode, actualHashcode)
}