blob: 60afb747b6a6a3ed9522bd84aa90373dcb6b0d1c [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Ash Wilson07a25bf2014-10-13 12:00:32 -04002
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
Jon Perritt27249f42016-02-18 10:35:59 -06008 th "github.com/gophercloud/gophercloud/testhelper"
9 "github.com/gophercloud/gophercloud/testhelper/client"
Ash Wilson07a25bf2014-10-13 12:00:32 -040010)
11
12// ListOutput provides a single Extension result. It differs from the delegated implementation
13// by the introduction of an intermediate "values" member.
14const 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.
33func 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}