Jon Perritt | 9a9c386 | 2015-01-19 17:16:22 -0700 | [diff] [blame] | 1 | package base |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | th "github.com/rackspace/gophercloud/testhelper" |
| 7 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 8 | ) |
| 9 | |
Jon Perritt | 01e211b | 2015-01-20 19:21:34 -0700 | [diff] [blame^] | 10 | func TestGetHomeDocument(t *testing.T) { |
Jon Perritt | 9a9c386 | 2015-01-19 17:16:22 -0700 | [diff] [blame] | 11 | th.SetupHTTP() |
| 12 | defer th.TeardownHTTP() |
| 13 | HandleGetSuccessfully(t) |
| 14 | |
| 15 | actual, err := Get(fake.ServiceClient()).Extract() |
| 16 | th.CheckNoErr(t, err) |
| 17 | |
| 18 | expected := HomeDocument{ |
| 19 | "rel/cdn": `{ |
| 20 | "href-template": "services{?marker,limit}", |
| 21 | "href-vars": { |
| 22 | "marker": "param/marker", |
| 23 | "limit": "param/limit" |
| 24 | }, |
| 25 | "hints": { |
| 26 | "allow": [ |
| 27 | "GET" |
| 28 | ], |
| 29 | "formats": { |
| 30 | "application/json": {} |
| 31 | } |
| 32 | } |
| 33 | }`, |
| 34 | } |
| 35 | th.CheckDeepEquals(t, expected, *actual) |
| 36 | } |
| 37 | |
Jon Perritt | 01e211b | 2015-01-20 19:21:34 -0700 | [diff] [blame^] | 38 | func TestPing(t *testing.T) { |
Jon Perritt | 9a9c386 | 2015-01-19 17:16:22 -0700 | [diff] [blame] | 39 | th.SetupHTTP() |
| 40 | defer th.TeardownHTTP() |
| 41 | HandlePingSuccessfully(t) |
| 42 | |
| 43 | err := Ping(fake.ServiceClient()).ExtractErr() |
| 44 | th.CheckNoErr(t, err) |
| 45 | } |