Skip to content

Commit a710da9

Browse files
committed
Fix bug in scs
1 parent 0d0aa26 commit a710da9

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

services/scs/client_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scs
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"github.com/baidubce/bce-sdk-go/model"
67
"os"
78
"path/filepath"
@@ -102,15 +103,19 @@ func TestClient_CreateInstance(t *testing.T) {
102103
ExpectEqual(t.Errorf, nil, err)
103104

104105
if len(result.InstanceIds) > 0 {
105-
SCS_TEST_ID = result.InstanceIds[0].InstanceId
106+
SCS_TEST_ID = result.InstanceIds[0]
106107
}
107108
isAvailable(SCS_TEST_ID)
109+
data, _ := json.Marshal(result)
110+
fmt.Println(string(data))
108111
}
109112

110113
func TestClient_ListInstances(t *testing.T) {
111114
args := &ListInstancesArgs{}
112115
result, err := SCS_CLIENT.ListInstances(args)
113116
ExpectEqual(t.Errorf, nil, err)
117+
data, _ := json.Marshal(result)
118+
fmt.Println(string(data))
114119
for _, e := range result.Instances {
115120
if e.InstanceID == SCS_TEST_ID {
116121
ExpectEqual(t.Errorf, "Postpaid", e.PaymentTiming)
@@ -120,8 +125,10 @@ func TestClient_ListInstances(t *testing.T) {
120125
}
121126

122127
func TestClient_GetInstanceDetail(t *testing.T) {
123-
_, err := SCS_CLIENT.GetInstanceDetail(SCS_TEST_ID)
128+
result, err := SCS_CLIENT.GetInstanceDetail("scs-su-vizlxyjqkfnm")
124129
ExpectEqual(t.Errorf, nil, err)
130+
data, _ := json.Marshal(result)
131+
fmt.Println(string(data))
125132
}
126133

127134
func TestClient_UpdateInstanceName(t *testing.T) {
@@ -297,6 +304,7 @@ func TestClient_AddSecurityIp(t *testing.T) {
297304
SecurityIps: []string{
298305
"192.0.0.1",
299306
},
307+
ClientToken: getClientToken(),
300308
}
301309
err := SCS_CLIENT.AddSecurityIp(e.InstanceID, args)
302310
ExpectEqual(t.Errorf, nil, err)
@@ -316,6 +324,7 @@ func TestClient_DeleteSecurityIp(t *testing.T) {
316324
SecurityIps: []string{
317325
"192.0.0.1",
318326
},
327+
ClientToken: getClientToken(),
319328
}
320329
err := SCS_CLIENT.DeleteSecurityIp(e.InstanceID, args)
321330
ExpectEqual(t.Errorf, nil, err)
@@ -348,6 +357,7 @@ func TestClient_ModifyParameters(t *testing.T) {
348357
Name: "timeout",
349358
Value: "0",
350359
},
360+
ClientToken: getClientToken(),
351361
}
352362
err := SCS_CLIENT.ModifyParameters(e.InstanceID, args)
353363
ExpectEqual(t.Errorf, nil, err)
@@ -379,6 +389,7 @@ func TestClient_ModifyBackupPolicy(t *testing.T) {
379389
BackupDays: "Sun,Mon,Tue,Wed,Thu,Fri,Sta",
380390
BackupTime: "01:05:00",
381391
ExpireDay: 7,
392+
ClientToken: getClientToken(),
382393
}
383394
err := SCS_CLIENT.ModifyBackupPolicy(e.InstanceID, args)
384395
ExpectEqual(t.Errorf, nil, err)

services/scs/model.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Billing struct {
3030
Reservation *Reservation `json:"reservation,omitempty"`
3131
}
3232

33-
type SubnetMap struct {
33+
type Subnet struct {
3434
ZoneName string `json:"zoneName"`
3535
SubnetID string `json:"subnetId"`
3636
}
@@ -49,19 +49,16 @@ type CreateInstanceArgs struct {
4949
Port int `json:"port"`
5050
EngineVersion string `json:"engineVersion"`
5151
VpcID string `json:"vpcId"`
52-
Subnets []SubnetMap `json:"subnets,omitempty"`
52+
Subnets []Subnet `json:"subnets,omitempty"`
5353
AutoRenewTimeUnit string `json:"autoRenewTimeUnit,omitempty"`
5454
AutoRenewTime int `json:"autoRenewTime,omitempty"`
5555
ClientToken string `json:"-"`
5656
}
5757

5858
type CreateInstanceResult struct {
59-
InstanceIds []InstanceId `json:"instanceIds"`
59+
InstanceIds []string `json:"instanceIds"`
6060
}
6161

62-
type InstanceId struct {
63-
InstanceId string `json:"instanceId"`
64-
}
6562
type InstanceModel struct {
6663
InstanceID string `json:"instanceId"`
6764
InstanceName string `json:"instanceName"`
@@ -73,11 +70,11 @@ type InstanceModel struct {
7370
Domain string `json:"domain"`
7471
Port int `json:"port"`
7572
InstanceCreateTime string `json:"instanceCreateTime"`
76-
InstanceExpireTime string `json:"instanceExpireTime"`
7773
Capacity int `json:"capacity"`
7874
UsedCapacity float64 `json:"usedCapacity"`
7975
PaymentTiming string `json:"paymentTiming"`
8076
ZoneNames []string `json:"zoneNames"`
77+
Tags []model.TagModel `json:"tags"`
8178
}
8279

8380
type ListInstancesArgs struct {
@@ -94,7 +91,6 @@ type ListInstancesResult struct {
9491
}
9592

9693
type ResizeInstanceArgs struct {
97-
Billing Billing `json:"billing"`
9894
NodeType string `json:"nodeType"`
9995
ShardNum int `json:"shardNum"`
10096
ClientToken string `json:"-"`
@@ -118,7 +114,8 @@ type GetInstanceDetailResult struct {
118114
VpcID string `json:"vpcId"`
119115
ZoneNames []string `json:"zoneNames"`
120116
Subnets []Subnet `json:"subnets"`
121-
AutoRenew bool `json:"autoRenew"`
117+
AutoRenew int `json:"autoRenew"`
118+
Tags []model.TagModel `json:"tags"`
122119
}
123120

124121
type UpdateInstanceNameArgs struct {
@@ -143,15 +140,15 @@ type GetNodeTypeListResult struct {
143140
}
144141

145142
type ListSubnetsArgs struct {
146-
VpcID string
147-
ZoneName string
143+
VpcID string `json:"vpcId"`
144+
ZoneName string `json:"zoneName"`
148145
}
149146

150147
type ListSubnetsResult struct {
151-
Subnets []Subnet `json:"subnets"`
148+
SubnetOriginals []SubnetOriginal `json:"subnets"`
152149
}
153150

154-
type Subnet struct {
151+
type SubnetOriginal struct {
155152
Name string `json:"name"`
156153
SubnetID string `json:"subnetId"`
157154
ZoneName string `json:"zoneName"`

0 commit comments

Comments
 (0)