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