github.com/gophercloud/gophercloud@v1.11.0/openstack/blockstorage/extensions/availabilityzones/testing/fixtures_test.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 az "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/availabilityzones" 9 th "github.com/gophercloud/gophercloud/testhelper" 10 "github.com/gophercloud/gophercloud/testhelper/client" 11 ) 12 13 const GetOutput = ` 14 { 15 "availabilityZoneInfo": [ 16 { 17 "zoneName": "internal", 18 "zoneState": { 19 "available": true 20 } 21 }, 22 { 23 "zoneName": "nova", 24 "zoneState": { 25 "available": true 26 } 27 } 28 ] 29 }` 30 31 var AZResult = []az.AvailabilityZone{ 32 { 33 ZoneName: "internal", 34 ZoneState: az.ZoneState{Available: true}, 35 }, 36 { 37 ZoneName: "nova", 38 ZoneState: az.ZoneState{Available: true}, 39 }, 40 } 41 42 // HandleGetSuccessfully configures the test server to respond to a Get request 43 // for availability zone information. 44 func HandleGetSuccessfully(t *testing.T) { 45 th.Mux.HandleFunc("/os-availability-zone", func(w http.ResponseWriter, r *http.Request) { 46 th.TestMethod(t, r, "GET") 47 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 48 49 w.Header().Add("Content-Type", "application/json") 50 fmt.Fprintf(w, GetOutput) 51 }) 52 }