Jamie Hannaford | 1ce30f2 | 2014-09-16 11:23:34 +0200 | [diff] [blame^] | 1 | package networks |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/rackspace/gophercloud" |
| 9 | th "github.com/rackspace/gophercloud/testhelper" |
| 10 | ) |
| 11 | |
| 12 | const TokenID = "123" |
| 13 | |
| 14 | func ServiceClient() *gophercloud.ServiceClient { |
| 15 | return &gophercloud.ServiceClient{ |
| 16 | Provider: &gophercloud.ProviderClient{ |
| 17 | TokenID: TokenID, |
| 18 | }, |
| 19 | Endpoint: th.Endpoint(), |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func TestList(t *testing.T) { |
| 24 | |
| 25 | } |
| 26 | |
| 27 | func TestGet(t *testing.T) { |
| 28 | th.SetupHTTP() |
| 29 | defer th.TeardownHTTP() |
| 30 | |
| 31 | th.Mux.HandleFunc("/v2.0/extension/agent", func(w http.ResponseWriter, r *http.Request) { |
| 32 | th.TestMethod(t, r, "GET") |
| 33 | th.TestHeader(t, r, "X-Auth-Token", TokenID) |
| 34 | |
| 35 | w.Header().Add("Content-Type", "application/json") |
| 36 | w.WriteHeader(http.StatusOK) |
| 37 | |
| 38 | fmt.Fprintf(w, ` |
| 39 | { |
| 40 | "extension": { |
| 41 | "updated": "2013-02-03T10:00:00-00:00", |
| 42 | "name": "agent", |
| 43 | "links": [], |
| 44 | "namespace": "http://docs.openstack.org/ext/agent/api/v2.0", |
| 45 | "alias": "agent", |
| 46 | "description": "The agent management extension." |
| 47 | } |
| 48 | } |
| 49 | `) |
| 50 | |
| 51 | ext, err := Get(ServiceClient(), "agent") |
| 52 | th.AssertNoErr(t, err) |
| 53 | |
| 54 | th.AssertEquals(t, ext.Updated, "2013-02-03T10:00:00-00:00") |
| 55 | th.AssertEquals(t, ext.Name, "agent") |
| 56 | th.AssertEquals(t, ext.Namespace, "http://docs.openstack.org/ext/agent/api/v2.0") |
| 57 | th.AssertEquals(t, ext.Alias, "agent") |
| 58 | th.AssertEquals(t, ext.Description, "The agent management extension.") |
| 59 | }) |
| 60 | } |