github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/dli/v1/queues/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/huaweicloud/golangsdk/openstack/dli/v1/queues" 9 th "github.com/huaweicloud/golangsdk/testhelper" 10 "github.com/huaweicloud/golangsdk/testhelper/client" 11 ) 12 13 const ( 14 expectedListResponse = ` 15 { 16 "is_success": true, 17 "message": "", 18 "queues": [ 19 { 20 "charging_mode": 1, 21 "cidr_in_mgntsubnet": "172.24.128.0/18", 22 "cidr_in_subnet": "172.24.0.0/18", 23 "cidr_in_vpc": "172.16.0.0/12", 24 "create_time": 1626771444081, 25 "cu_count": 16, 26 "description": "", 27 "feature": "basic", 28 "is_restarting": false, 29 "labels": "", 30 "max_cu_count": 100, 31 "owner": "niuzhenguo", 32 "platform": "x86_64", 33 "queue_name": "tf_acc_test_dli_queue_h8yr3", 34 "queue_resource_type": "vm", 35 "queue_type": "sql", 36 "resource_id": "b483aa39-ab65-442b-8c20-2f578a9d868b", 37 "resource_mode": 1 38 } 39 ] 40 }` 41 ) 42 43 var ( 44 expectedListResponseData = queues.Queue{ 45 QueueName: "tf_acc_test_dli_queue_h8yr3", 46 Description: "", 47 Owner: "niuzhenguo", 48 CreateTime: 1626771444081, 49 QueueType: "sql", 50 CuCount: 16, 51 ChargingMode: 1, 52 ResourceId: "b483aa39-ab65-442b-8c20-2f578a9d868b", 53 EnterpriseProjectId: "", 54 CidrInVpc: "172.16.0.0/12", 55 CidrInMgntsubnet: "172.24.128.0/18", 56 CidrInSubnet: "172.24.0.0/18", 57 ResourceMode: 1, 58 Platform: "x86_64", 59 IsRestarting: false, 60 Feature: "basic", 61 QueueResourceType: "vm", 62 } 63 ) 64 65 var ( 66 mockScaleActionResponse = ` 67 { 68 "queue_name": "tf_acc_test_dli_queue_h8yr3", 69 "result": true 70 }` 71 ) 72 73 var queueName1 = "tf_acc_test_dli_queue_h8yr3" 74 75 func handleList(t *testing.T) { 76 th.Mux.HandleFunc("/queues/", func(w http.ResponseWriter, r *http.Request) { 77 th.TestMethod(t, r, "GET") 78 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 79 w.Header().Add("Content-Type", "application/json") 80 w.WriteHeader(http.StatusOK) 81 _, _ = fmt.Fprint(w, expectedListResponse) 82 }) 83 } 84 85 func handleScale(t *testing.T) { 86 th.Mux.HandleFunc("/queues/"+queueName1+"/action", func(w http.ResponseWriter, r *http.Request) { 87 th.TestMethod(t, r, "PUT") 88 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 89 w.Header().Add("Content-Type", "application/json") 90 w.WriteHeader(http.StatusOK) 91 _, _ = fmt.Fprint(w, mockScaleActionResponse) 92 }) 93 }