jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame^] | 1 | package testing |
Ash Wilson | 07a25bf | 2014-10-13 12:00:32 -0400 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 8 | th "github.com/gophercloud/gophercloud/testhelper" |
| 9 | "github.com/gophercloud/gophercloud/testhelper/client" |
Ash Wilson | 07a25bf | 2014-10-13 12:00:32 -0400 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | // ListOutput provides a single Extension result. It differs from the delegated implementation |
| 13 | // by the introduction of an intermediate "values" member. |
| 14 | const ListOutput = ` |
| 15 | { |
| 16 | "extensions": { |
| 17 | "values": [ |
| 18 | { |
| 19 | "updated": "2013-01-20T00:00:00-00:00", |
| 20 | "name": "Neutron Service Type Management", |
| 21 | "links": [], |
| 22 | "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", |
| 23 | "alias": "service-type", |
| 24 | "description": "API for retrieving service providers for Neutron advanced services" |
| 25 | } |
| 26 | ] |
| 27 | } |
| 28 | } |
| 29 | ` |
| 30 | |
| 31 | // HandleListExtensionsSuccessfully creates an HTTP handler that returns ListOutput for a List |
| 32 | // call. |
| 33 | func HandleListExtensionsSuccessfully(t *testing.T) { |
| 34 | th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) { |
| 35 | th.TestMethod(t, r, "GET") |
| 36 | th.TestHeader(t, r, "X-Auth-Token", client.TokenID) |
| 37 | |
| 38 | w.Header().Add("Content-Type", "application/json") |
| 39 | |
| 40 | fmt.Fprintf(w, ` |
| 41 | { |
| 42 | "extensions": { |
| 43 | "values": [ |
| 44 | { |
| 45 | "updated": "2013-01-20T00:00:00-00:00", |
| 46 | "name": "Neutron Service Type Management", |
| 47 | "links": [], |
| 48 | "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", |
| 49 | "alias": "service-type", |
| 50 | "description": "API for retrieving service providers for Neutron advanced services" |
| 51 | } |
| 52 | ] |
| 53 | } |
| 54 | } |
| 55 | `) |
| 56 | }) |
| 57 | |
| 58 | } |