This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
fixtures.go
93 lines (85 loc) · 2.33 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
package testing
import (
"fmt"
"net/http"
"testing"
"github.com/huaweicloud/golangsdk/openstack/dli/v1/queues"
th "github.com/huaweicloud/golangsdk/testhelper"
"github.com/huaweicloud/golangsdk/testhelper/client"
)
const (
expectedListResponse = `
{
"is_success": true,
"message": "",
"queues": [
{
"charging_mode": 1,
"cidr_in_mgntsubnet": "172.24.128.0/18",
"cidr_in_subnet": "172.24.0.0/18",
"cidr_in_vpc": "172.16.0.0/12",
"create_time": 1626771444081,
"cu_count": 16,
"description": "",
"feature": "basic",
"is_restarting": false,
"labels": "",
"max_cu_count": 100,
"owner": "niuzhenguo",
"platform": "x86_64",
"queue_name": "tf_acc_test_dli_queue_h8yr3",
"queue_resource_type": "vm",
"queue_type": "sql",
"resource_id": "b483aa39-ab65-442b-8c20-2f578a9d868b",
"resource_mode": 1
}
]
}`
)
var (
expectedListResponseData = queues.Queue{
QueueName: "tf_acc_test_dli_queue_h8yr3",
Description: "",
Owner: "niuzhenguo",
CreateTime: 1626771444081,
QueueType: "sql",
CuCount: 16,
ChargingMode: 1,
ResourceId: "b483aa39-ab65-442b-8c20-2f578a9d868b",
EnterpriseProjectId: "",
CidrInVpc: "172.16.0.0/12",
CidrInMgntsubnet: "172.24.128.0/18",
CidrInSubnet: "172.24.0.0/18",
ResourceMode: 1,
Platform: "x86_64",
IsRestarting: false,
Feature: "basic",
QueueResourceType: "vm",
}
)
var (
mockScaleActionResponse = `
{
"queue_name": "tf_acc_test_dli_queue_h8yr3",
"result": true
}`
)
var queueName1 = "tf_acc_test_dli_queue_h8yr3"
func handleList(t *testing.T) {
th.Mux.HandleFunc("/queues/", 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.Fprint(w, expectedListResponse)
})
}
func handleScale(t *testing.T) {
th.Mux.HandleFunc("/queues/"+queueName1+"/action", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprint(w, mockScaleActionResponse)
})
}