github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 th "github.com/huaweicloud/golangsdk/testhelper" 9 "github.com/huaweicloud/golangsdk/testhelper/client" 10 ) 11 12 func HandleListExtensionsSuccessfully(t *testing.T) { 13 th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) { 14 th.TestMethod(t, r, "GET") 15 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 16 17 w.Header().Add("Content-Type", "application/json") 18 19 fmt.Fprintf(w, ` 20 { 21 "extensions": [ 22 { 23 "updated": "2013-01-20T00:00:00-00:00", 24 "name": "Neutron Service Type Management", 25 "links": [], 26 "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0", 27 "alias": "service-type", 28 "description": "API for retrieving service providers for Neutron advanced services" 29 } 30 ] 31 } 32 `) 33 }) 34 } 35 36 func HandleGetExtensionsSuccessfully(t *testing.T) { 37 th.Mux.HandleFunc("/extensions/agent", func(w http.ResponseWriter, r *http.Request) { 38 th.TestMethod(t, r, "GET") 39 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 40 41 w.Header().Add("Content-Type", "application/json") 42 w.WriteHeader(http.StatusOK) 43 44 fmt.Fprintf(w, ` 45 { 46 "extension": { 47 "updated": "2013-02-03T10:00:00-00:00", 48 "name": "agent", 49 "links": [], 50 "namespace": "http://docs.openstack.org/ext/agent/api/v2.0", 51 "alias": "agent", 52 "description": "The agent management extension." 53 } 54 } 55 `) 56 }) 57 }