Ash Wilson | 0e5b92a | 2014-10-23 11:42:04 -0400 | [diff] [blame] | 1 | package diskconfig |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/rackspace/gophercloud/openstack/compute/v2/servers" |
| 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | "github.com/rackspace/gophercloud/testhelper/client" |
| 9 | ) |
| 10 | |
| 11 | func TestExtractGet(t *testing.T) { |
| 12 | th.SetupHTTP() |
| 13 | defer th.TeardownHTTP() |
| 14 | servers.HandleServerGetSuccessfully(t) |
| 15 | |
| 16 | config, err := ExtractGet(servers.Get(client.ServiceClient(), "1234asdf")) |
| 17 | th.AssertNoErr(t, err) |
| 18 | th.CheckEquals(t, Manual, *config) |
| 19 | } |
| 20 | |
| 21 | func TestExtractUpdate(t *testing.T) { |
| 22 | th.SetupHTTP() |
| 23 | defer th.TeardownHTTP() |
| 24 | servers.HandleServerUpdateSuccessfully(t) |
| 25 | |
| 26 | r := servers.Update(client.ServiceClient(), "1234asdf", servers.UpdateOpts{ |
| 27 | Name: "new-name", |
| 28 | }) |
| 29 | config, err := ExtractUpdate(r) |
| 30 | th.AssertNoErr(t, err) |
| 31 | th.CheckEquals(t, Manual, *config) |
| 32 | } |
| 33 | |
| 34 | func TestExtractRebuild(t *testing.T) { |
| 35 | th.SetupHTTP() |
| 36 | defer th.TeardownHTTP() |
| 37 | servers.HandleRebuildSuccessfully(t, servers.SingleServerBody) |
| 38 | |
| 39 | r := servers.Rebuild(client.ServiceClient(), "1234asdf", servers.RebuildOpts{ |
| 40 | Name: "new-name", |
| 41 | AdminPass: "swordfish", |
| 42 | ImageID: "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb", |
| 43 | AccessIPv4: "1.2.3.4", |
| 44 | }) |
| 45 | config, err := ExtractRebuild(r) |
| 46 | th.AssertNoErr(t, err) |
| 47 | th.CheckEquals(t, Manual, *config) |
| 48 | } |