github.com/gophercloud/gophercloud@v1.11.0/openstack/containerinfra/apiversions/testing/fixtures_test.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/gophercloud/gophercloud/openstack/containerinfra/apiversions" 9 th "github.com/gophercloud/gophercloud/testhelper" 10 "github.com/gophercloud/gophercloud/testhelper/client" 11 ) 12 13 const MagnumAPIVersionResponse = ` 14 { 15 "versions":[ 16 { 17 "status":"CURRENT", 18 "min_version":"1.1", 19 "max_version":"1.7", 20 "id":"v1", 21 "links":[ 22 { 23 "href":"http://10.164.180.104:9511/v1/", 24 "rel":"self" 25 } 26 ] 27 } 28 ], 29 "name":"OpenStack Magnum API", 30 "description":"Magnum is an OpenStack project which aims to provide container management." 31 } 32 ` 33 34 const MagnumAllAPIVersionsResponse = ` 35 { 36 "versions":[ 37 { 38 "status":"CURRENT", 39 "min_version":"1.1", 40 "max_version":"1.7", 41 "id":"v1", 42 "links":[ 43 { 44 "href":"http://10.164.180.104:9511/v1/", 45 "rel":"self" 46 } 47 ] 48 } 49 ], 50 "name":"OpenStack Magnum API", 51 "description":"Magnum is an OpenStack project which aims to provide container management." 52 } 53 ` 54 55 var MagnumAPIVersion1Result = apiversions.APIVersion{ 56 ID: "v1", 57 Status: "CURRENT", 58 MinVersion: "1.1", 59 Version: "1.7", 60 } 61 62 var MagnumAllAPIVersionResults = []apiversions.APIVersion{ 63 MagnumAPIVersion1Result, 64 } 65 66 func MockListResponse(t *testing.T) { 67 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 68 th.TestMethod(t, r, "GET") 69 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 70 71 w.Header().Add("Content-Type", "application/json") 72 w.WriteHeader(http.StatusOK) 73 74 fmt.Fprintf(w, MagnumAllAPIVersionsResponse) 75 }) 76 } 77 78 func MockGetResponse(t *testing.T) { 79 th.Mux.HandleFunc("/v1/", func(w http.ResponseWriter, r *http.Request) { 80 th.TestMethod(t, r, "GET") 81 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 82 83 w.Header().Add("Content-Type", "application/json") 84 w.WriteHeader(http.StatusOK) 85 86 fmt.Fprintf(w, MagnumAPIVersionResponse) 87 }) 88 }