forked from huaweicloud/huaweicloud-sdk-go
/
fixtures.go
95 lines (92 loc) · 2.15 KB
/
fixtures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package testing
import (
"fmt"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
"net/http"
"testing"
)
const FlavorsMysqlResp = `
{
"flavors": [{
"vcpus": "1",
"ram": 2,
"spec_code": "rds.mysql.c2.medium.ha",
"instance_mode": "ha"
}, {
"vcpus": "1",
"ram": 2,
"spec_code": "rds.mysql.c2.medium.rr",
"instance_mode": "replica"
}]
}
`
const FlavorsPostgreSQLResp = `
{
"flavors": [{
"vcpus": "2",
"ram": 4,
"spec_code": "rds.pg.c2.large",
"instance_mode": "single",
"az_status": {
"az2xahz": "normal",
"az1xahz": "normal",
"az3xahz": "normal"
}
},{
"vcpus": "48",
"ram": 384,
"spec_code": "rds.pg.i3.12xlarge.8",
"instance_mode": "single",
"az_status": {
"az2xahz": "unsupported",
"az1xahz": "unsupported",
"az3xahz": "unsupported"
}
}, {
"vcpus": "60",
"ram": 512,
"spec_code": "rds.pg.i3.15xlarge.8",
"instance_mode": "single",
"az_status": {
"az2xahz": "unsupported",
"az1xahz": "unsupported",
"az3xahz": "unsupported"
}
}, {
"vcpus": "48",
"ram": 384,
"spec_code": "rds.pg.i3.12xlarge.8.ha",
"instance_mode": "ha",
"az_status": {
"az2xahz": "unsupported",
"az1xahz": "unsupported",
"az3xahz": "unsupported"
}
}]
}
`
func HandleListMysqlSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/flavors/MySQL", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, FlavorsMysqlResp)
params := r.URL.Query()
versionname := params.Get("version_name")
th.CheckEquals(t, "5.7", versionname)
})
}
func HandleListPgSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/flavors/PostgreSQL", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, FlavorsPostgreSQLResp)
params := r.URL.Query()
versionname := params.Get("version_name")
th.CheckEquals(t, "9.6", versionname)
})
}