|
8 | 8 | "github.com/gophercloud/gophercloud/acceptance/clients" |
9 | 9 | "github.com/gophercloud/gophercloud/acceptance/tools" |
10 | 10 | "github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumetypes" |
| 11 | + th "github.com/gophercloud/gophercloud/testhelper" |
11 | 12 | ) |
12 | 13 |
|
13 | 14 | func TestVolumeTypesList(t *testing.T) { |
@@ -36,7 +37,7 @@ func TestVolumeTypesList(t *testing.T) { |
36 | 37 | } |
37 | 38 |
|
38 | 39 | if len(allVolumeTypes) > 0 { |
39 | | - vt, err := volumetypes.Get(client, allVolumes[0].ID).Extract() |
| 40 | + vt, err := volumetypes.Get(client, allVolumeTypes[0].ID).Extract() |
40 | 41 | if err != nil { |
41 | 42 | t.Fatalf("Error retrieving volume type: %v", err) |
42 | 43 | } |
@@ -65,3 +66,30 @@ func TestVolumeTypesCreate(t *testing.T) { |
65 | 66 |
|
66 | 67 | tools.PrintResource(t, vt) |
67 | 68 | } |
| 69 | + |
| 70 | +func TestVolumeTypesUpdate(t *testing.T) { |
| 71 | + client, err := clients.NewBlockStorageV3Client() |
| 72 | + if err != nil { |
| 73 | + t.Fatalf("Unable to create a blockstorage client: %v", err) |
| 74 | + } |
| 75 | + |
| 76 | + createOpts := volumetypes.CreateOpts{ |
| 77 | + Name: "create_for_update", |
| 78 | + PublicAccess: true, |
| 79 | + ExtraSpecs: map[string]string{"volume_backend_name": "fake_backend_name"}, |
| 80 | + Description: "create_for_update", |
| 81 | + } |
| 82 | + |
| 83 | + vt, err := volumetypes.Create(client, createOpts).Extract() |
| 84 | + if err != nil { |
| 85 | + t.Fatalf("Unable to create volumetype: %v", err) |
| 86 | + } |
| 87 | + |
| 88 | + newVT, err := volumetypes.Update(client, vt.ID, volumetypes.UpdateOpts{Name: "updated_volume_type"}).Extract() |
| 89 | + if err != nil { |
| 90 | + t.Fatalf("Unable to update volumetype: %v", err) |
| 91 | + } |
| 92 | + th.AssertEquals(t, "updated_volume_type", newVT.Name) |
| 93 | + |
| 94 | + tools.PrintResource(t, vt) |
| 95 | +} |
0 commit comments