Joe Topjian | 520307e | 2015-02-07 05:22:12 +0000 | [diff] [blame] | 1 | package volumeattach |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/rackspace/gophercloud/pagination" |
| 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | "github.com/rackspace/gophercloud/testhelper/client" |
| 9 | ) |
| 10 | |
| 11 | func TestList(t *testing.T) { |
| 12 | th.SetupHTTP() |
| 13 | defer th.TeardownHTTP() |
| 14 | HandleListSuccessfully(t) |
| 15 | serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0" |
| 16 | |
| 17 | count := 0 |
| 18 | err := List(client.ServiceClient(), serverId).EachPage(func(page pagination.Page) (bool, error) { |
| 19 | count++ |
| 20 | actual, err := ExtractVolumeAttachments(page) |
| 21 | th.AssertNoErr(t, err) |
| 22 | th.CheckDeepEquals(t, ExpectedVolumeAttachmentSlice, actual) |
| 23 | |
| 24 | return true, nil |
| 25 | }) |
| 26 | th.AssertNoErr(t, err) |
| 27 | th.CheckEquals(t, 1, count) |
| 28 | } |
| 29 | |
| 30 | func TestCreate(t *testing.T) { |
| 31 | th.SetupHTTP() |
| 32 | defer th.TeardownHTTP() |
| 33 | HandleCreateSuccessfully(t) |
| 34 | serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0" |
| 35 | |
| 36 | actual, err := Create(client.ServiceClient(), serverId, CreateOpts{ |
| 37 | Device: "/dev/vdc", |
| 38 | VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804", |
Joe Topjian | 520307e | 2015-02-07 05:22:12 +0000 | [diff] [blame] | 39 | }).Extract() |
| 40 | th.AssertNoErr(t, err) |
| 41 | th.CheckDeepEquals(t, &CreatedVolumeAttachment, actual) |
| 42 | } |
| 43 | |
| 44 | func TestGet(t *testing.T) { |
| 45 | th.SetupHTTP() |
| 46 | defer th.TeardownHTTP() |
| 47 | HandleGetSuccessfully(t) |
| 48 | aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804" |
| 49 | serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0" |
| 50 | |
| 51 | actual, err := Get(client.ServiceClient(), serverId, aId).Extract() |
| 52 | th.AssertNoErr(t, err) |
| 53 | th.CheckDeepEquals(t, &SecondVolumeAttachment, actual) |
| 54 | } |
| 55 | |
| 56 | func TestDelete(t *testing.T) { |
| 57 | th.SetupHTTP() |
| 58 | defer th.TeardownHTTP() |
| 59 | HandleDeleteSuccessfully(t) |
| 60 | aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804" |
| 61 | serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0" |
| 62 | |
| 63 | err := Delete(client.ServiceClient(), serverId, aId).ExtractErr() |
| 64 | th.AssertNoErr(t, err) |
| 65 | } |