github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/limits/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/limits" 9 th "github.com/huaweicloud/golangsdk/testhelper" 10 "github.com/huaweicloud/golangsdk/testhelper/client" 11 ) 12 13 // GetOutput is a sample response to a Get call. 14 const GetOutput = ` 15 { 16 "limits": { 17 "rate": [], 18 "absolute": { 19 "maxServerMeta": 128, 20 "maxPersonality": 5, 21 "totalServerGroupsUsed": 0, 22 "maxImageMeta": 128, 23 "maxPersonalitySize": 10240, 24 "maxTotalKeypairs": 100, 25 "maxSecurityGroupRules": 20, 26 "maxServerGroups": 10, 27 "totalCoresUsed": 1, 28 "totalRAMUsed": 2048, 29 "totalInstancesUsed": 1, 30 "maxSecurityGroups": 10, 31 "totalFloatingIpsUsed": 0, 32 "maxTotalCores": 20, 33 "maxServerGroupMembers": 10, 34 "maxTotalFloatingIps": 10, 35 "totalSecurityGroupsUsed": 1, 36 "maxTotalInstances": 10, 37 "maxTotalRAMSize": 51200 38 } 39 } 40 } 41 ` 42 43 // LimitsResult is the result of the limits in GetOutput. 44 var LimitsResult = limits.Limits{ 45 Absolute: limits.Absolute{ 46 MaxServerMeta: 128, 47 MaxPersonality: 5, 48 TotalServerGroupsUsed: 0, 49 MaxImageMeta: 128, 50 MaxPersonalitySize: 10240, 51 MaxTotalKeypairs: 100, 52 MaxSecurityGroupRules: 20, 53 MaxServerGroups: 10, 54 TotalCoresUsed: 1, 55 TotalRAMUsed: 2048, 56 TotalInstancesUsed: 1, 57 MaxSecurityGroups: 10, 58 TotalFloatingIpsUsed: 0, 59 MaxTotalCores: 20, 60 MaxServerGroupMembers: 10, 61 MaxTotalFloatingIps: 10, 62 TotalSecurityGroupsUsed: 1, 63 MaxTotalInstances: 10, 64 MaxTotalRAMSize: 51200, 65 }, 66 } 67 68 const TenantID = "555544443333222211110000ffffeeee" 69 70 // HandleGetSuccessfully configures the test server to respond to a Get request 71 // for a limit. 72 func HandleGetSuccessfully(t *testing.T) { 73 th.Mux.HandleFunc("/limits", func(w http.ResponseWriter, r *http.Request) { 74 th.TestMethod(t, r, "GET") 75 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 76 77 w.Header().Add("Content-Type", "application/json") 78 fmt.Fprintf(w, GetOutput) 79 }) 80 }