blob: 3fef872b3d2b838320bea54567a7177ebe525aa0 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Dan Kirkwoodceb84092016-03-01 13:58:34 -07002
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
jrperritt3d966162016-06-06 14:08:54 -05008 "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets"
9 th "github.com/gophercloud/gophercloud/testhelper"
10 "github.com/gophercloud/gophercloud/testhelper/client"
Dan Kirkwoodceb84092016-03-01 13:58:34 -070011)
12
13// GetOutput is a sample response to a Get call.
14const 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
31const FirstTenantID = "555544443333222211110000ffffeeee"
32
Dan Kirkwood7e8d8ed2016-03-08 14:05:57 -070033// FirstQuotaSet is the first result in ListOutput.
jrperritt3d966162016-06-06 14:08:54 -050034var FirstQuotaSet = quotasets.QuotaSet{
Dan Kirkwoodceb84092016-03-01 13:58:34 -070035 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
50func 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}