blob: 3fd5ad9b0ec7463c8f78b6ba88e73e867fecb122 [file] [log] [blame]
Ash Wilson07a25bf2014-10-13 12:00:32 -04001// +build fixtures
2
3package extensions
4
5import (
6 "fmt"
7 "net/http"
8 "testing"
9
Jon Perritt27249f42016-02-18 10:35:59 -060010 th "github.com/gophercloud/gophercloud/testhelper"
11 "github.com/gophercloud/gophercloud/testhelper/client"
Ash Wilson07a25bf2014-10-13 12:00:32 -040012)
13
14// ListOutput provides a single Extension result. It differs from the delegated implementation
15// by the introduction of an intermediate "values" member.
16const 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.
35func 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}