github.com/gophercloud/gophercloud@v1.11.0/openstack/loadbalancer/v2/apiversions/testing/fixture.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/apiversions" 9 th "github.com/gophercloud/gophercloud/testhelper" 10 "github.com/gophercloud/gophercloud/testhelper/client" 11 ) 12 13 const OctaviaAllAPIVersionsResponse = ` 14 { 15 "versions": [ 16 { 17 "id": "v1", 18 "links": [ 19 { 20 "href": "http://10.0.0.105:9876/v1", 21 "rel": "self" 22 } 23 ], 24 "status": "DEPRECATED", 25 "updated": "2014-12-11T00:00:00Z" 26 }, 27 { 28 "id": "v2.0", 29 "links": [ 30 { 31 "href": "http://10.0.0.105:9876/v2", 32 "rel": "self" 33 } 34 ], 35 "status": "SUPPORTED", 36 "updated": "2016-12-11T00:00:00Z" 37 }, 38 { 39 "id": "v2.1", 40 "links": [ 41 { 42 "href": "http://10.0.0.105:9876/v2", 43 "rel": "self" 44 } 45 ], 46 "status": "SUPPORTED", 47 "updated": "2018-04-20T00:00:00Z" 48 }, 49 { 50 "id": "v2.2", 51 "links": [ 52 { 53 "href": "http://10.0.0.105:9876/v2", 54 "rel": "self" 55 } 56 ], 57 "status": "CURRENT", 58 "updated": "2018-07-31T00:00:00Z" 59 } 60 ] 61 } 62 ` 63 64 var OctaviaAllAPIVersionResults = []apiversions.APIVersion{ 65 { 66 ID: "v1", 67 Status: "DEPRECATED", 68 }, 69 { 70 ID: "v2.0", 71 Status: "SUPPORTED", 72 }, 73 { 74 ID: "v2.1", 75 Status: "SUPPORTED", 76 }, 77 { 78 ID: "v2.2", 79 Status: "CURRENT", 80 }, 81 } 82 83 func MockListResponse(t *testing.T) { 84 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 85 th.TestMethod(t, r, "GET") 86 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 87 88 w.Header().Add("Content-Type", "application/json") 89 w.WriteHeader(http.StatusOK) 90 91 fmt.Fprintf(w, OctaviaAllAPIVersionsResponse) 92 }) 93 }