jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame^] | 1 | package testing |
Dan Kirkwood | ceb8409 | 2016-03-01 13:58:34 -0700 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame^] | 8 | "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets" |
| 9 | th "github.com/gophercloud/gophercloud/testhelper" |
| 10 | "github.com/gophercloud/gophercloud/testhelper/client" |
Dan Kirkwood | ceb8409 | 2016-03-01 13:58:34 -0700 | [diff] [blame] | 11 | ) |
| 12 | |
| 13 | // GetOutput is a sample response to a Get call. |
| 14 | const GetOutput = ` |
| 15 | { |
| 16 | "quota_set" : { |
| 17 | "instances" : 25, |
| 18 | "security_groups" : 10, |
| 19 | "security_group_rules" : 20, |
| 20 | "cores" : 200, |
| 21 | "injected_file_content_bytes" : 10240, |
| 22 | "injected_files" : 5, |
| 23 | "metadata_items" : 128, |
| 24 | "ram" : 200000, |
| 25 | "keypairs" : 10, |
| 26 | "injected_file_path_bytes" : 255 |
| 27 | } |
| 28 | } |
| 29 | ` |
| 30 | |
| 31 | const FirstTenantID = "555544443333222211110000ffffeeee" |
| 32 | |
Dan Kirkwood | 7e8d8ed | 2016-03-08 14:05:57 -0700 | [diff] [blame] | 33 | // FirstQuotaSet is the first result in ListOutput. |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame^] | 34 | var FirstQuotaSet = quotasets.QuotaSet{ |
Dan Kirkwood | ceb8409 | 2016-03-01 13:58:34 -0700 | [diff] [blame] | 35 | FixedIps: 0, |
| 36 | FloatingIps: 0, |
| 37 | InjectedFileContentBytes: 10240, |
| 38 | InjectedFilePathBytes: 255, |
| 39 | InjectedFiles: 5, |
| 40 | KeyPairs: 10, |
| 41 | MetadataItems: 128, |
| 42 | Ram: 200000, |
| 43 | SecurityGroupRules: 20, |
| 44 | SecurityGroups: 10, |
| 45 | Cores: 200, |
| 46 | Instances: 25, |
| 47 | } |
| 48 | |
| 49 | // HandleGetSuccessfully configures the test server to respond to a Get request for sample tenant |
| 50 | func HandleGetSuccessfully(t *testing.T) { |
| 51 | th.Mux.HandleFunc("/os-quota-sets/"+FirstTenantID, func(w http.ResponseWriter, r *http.Request) { |
| 52 | th.TestMethod(t, r, "GET") |
| 53 | th.TestHeader(t, r, "X-Auth-Token", client.TokenID) |
| 54 | |
| 55 | w.Header().Add("Content-Type", "application/json") |
| 56 | fmt.Fprintf(w, GetOutput) |
| 57 | }) |
| 58 | } |