Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ type ImageServerStub struct {
}

type VolumeStub struct {
Type string `json:"type"`
DevicePath string `json:"device_path"`
SizeGB int `json:"size_gb"`
UUID string `json:"uuid"`
HREF string `json:"href"`
UUID string `json:"uuid"`
Name string `json:"name"`
Type string `json:"type"`
SizeGB int `json:"size_gb"`
}

type Interface struct {
Expand Down
19 changes: 15 additions & 4 deletions test/integration/servers_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,32 @@ func TestIntegrationServer_MultipleVolumes(t *testing.T) {
t.Fatalf("Servers.WaitFor returned error %s\n", err)
}

// Ignore UUIDs in this comparison
// Ignore instance-specific fields in this comparison
actual := make([]cloudscale.VolumeStub, len(server.Volumes))
copy(actual, server.Volumes)
for i := range actual {
actual[i].UUID = ""
actual[i].HREF = ""
actual[i].Name = ""
}
expected := []cloudscale.VolumeStub{
{Type: "ssd", DevicePath: "", SizeGB: 10, UUID: ""},
{Type: "ssd", DevicePath: "", SizeGB: 3, UUID: ""},
{Type: "bulk", DevicePath: "", SizeGB: 100, UUID: ""},
{Type: "ssd", SizeGB: 10},
{Type: "ssd", SizeGB: 3},
{Type: "bulk", SizeGB: 100},
}
if !reflect.DeepEqual(actual, expected) {
t.Errorf("Volumes response\n got=%#v\nwant=%#v", actual, expected)
}

for _, volume := range server.Volumes {
if volume.HREF == "" {
t.Errorf("Expected volume HREF to be non-empty for UUID %s", volume.UUID)
}
if volume.Name == "" {
t.Errorf("Expected volume Name to be non-empty for UUID %s", volume.UUID)
}
}

// delete all volume, except the root volume
for _, volume := range server.Volumes[1:] {
volumeUUID := volume.UUID
Expand Down
6 changes: 6 additions & 0 deletions test/integration/volume_snapshots_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func TestIntegrationVolumeSnapshot_CRUD(t *testing.T) {
if retrieved.SourceVolume.UUID != volume.UUID {
t.Errorf("Expected retrieved snapshot SourceVolume.UUID to be %s, got %q", volume.UUID, retrieved.SourceVolume.UUID)
}
if retrieved.SourceVolume.Name != volume.Name {
t.Errorf("Expected SourceVolume.Name %q, got %q", volume.Name, retrieved.SourceVolume.Name)
}
if retrieved.SourceVolume.HREF == "" {
t.Error("Expected SourceVolume.HREF to be non-empty")
}

snapshots, err := client.VolumeSnapshots.List(ctx)
if err != nil {
Expand Down
20 changes: 13 additions & 7 deletions volume_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ package cloudscale

const volumeSnapshotsBasePath = "v1/volume-snapshots"

type SourceVolumeStub struct {
HREF string `json:"href"`
UUID string `json:"uuid"`
Name string `json:"name"`
}

type VolumeSnapshot struct {
ZonalResource
TaggedResource
HREF string `json:"href,omitempty"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name,omitempty"`
SizeGB int `json:"size_gb,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
SourceVolume VolumeStub `json:"source_volume,omitempty"`
Status string `json:"status,omitempty"`
HREF string `json:"href,omitempty"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name,omitempty"`
SizeGB int `json:"size_gb,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
SourceVolume SourceVolumeStub `json:"source_volume,omitempty"`
Status string `json:"status,omitempty"`
}

type VolumeSnapshotCreateRequest struct {
Expand Down