-
Notifications
You must be signed in to change notification settings - Fork 91
/
bucket_part_test.go
121 lines (115 loc) · 3.12 KB
/
bucket_part_test.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package cos
import (
"context"
"encoding/xml"
"fmt"
"net/http"
"reflect"
"testing"
)
func TestBucketService_ListMultipartUploads(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
vs := values{
"uploads": "",
"prefix": "t",
}
testFormValues(t, r, vs)
fmt.Fprint(w, `<ListMultipartUploadsResult>
<Bucket>test-1253846586</Bucket>
<Encoding-Type/>
<KeyMarker/>
<UploadIdMarker/>
<MaxUploads>1000</MaxUploads>
<Prefix>t</Prefix>
<Delimiter>/</Delimiter>
<IsTruncated>false</IsTruncated>
<CommonPrefixs>
<Prefix>test/</Prefix>
</CommonPrefixs>
<Upload>
<Key>test_multipart.txt</Key>
<UploadId>14972623850a5de3f4f10605ab9f339c8bdf1b77e06f03fb981e7e76c86554b7bdb6072b36</UploadId>
<Initiator>
<ID>100000760461/100000760461</ID>
<DisplayName/>
</Initiator>
<Owner>
<ID>100000760461/100000760461</ID>
<DisplayName/>
</Owner>
<StorageClass>STANDARD</StorageClass>
<Initiated>2017-06-12T10:13:05.000Z</Initiated>
</Upload>
<Upload>
<Key>test_multipar2t.txt</Key>
<UploadId>1497515958744e899fc341bfbb995ebd57b395f63930411d855aaac1b5cd7d834a15442831</UploadId>
<Initiator>
<ID>qcs::cam::uin/100000760461:uin/100000760461</ID>
<DisplayName>100000760461</DisplayName>
</Initiator>
<Owner>
<ID>qcs::cam::uin/100000760461:uin/100000760461</ID>
<DisplayName>100000760461</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
<Initiated>2017-06-15T08:39:18.000Z</Initiated>
</Upload>
</ListMultipartUploadsResult>`)
})
opt := &ListMultipartUploadsOptions{
Prefix: "t",
}
ref, _, err := client.Bucket.ListMultipartUploads(context.Background(), opt)
if err != nil {
t.Fatalf("Bucket.ListMultipartUploads returned error: %v", err)
}
want := &ListMultipartUploadsResult{
XMLName: xml.Name{Local: "ListMultipartUploadsResult"},
Bucket: "test-1253846586",
MaxUploads: 1000,
IsTruncated: false,
Uploads: []struct {
Key string
UploadID string `xml:"UploadId"`
StorageClass string
Initiator *Initiator
Owner *Owner
Initiated string
}{
{
Key: "test_multipart.txt",
UploadID: "14972623850a5de3f4f10605ab9f339c8bdf1b77e06f03fb981e7e76c86554b7bdb6072b36",
Initiator: &Initiator{
ID: "100000760461/100000760461",
},
Owner: &Owner{
ID: "100000760461/100000760461",
},
StorageClass: "STANDARD",
Initiated: "2017-06-12T10:13:05.000Z",
},
{
Key: "test_multipar2t.txt",
UploadID: "1497515958744e899fc341bfbb995ebd57b395f63930411d855aaac1b5cd7d834a15442831",
Initiator: &Initiator{
ID: "qcs::cam::uin/100000760461:uin/100000760461",
DisplayName: "100000760461",
},
Owner: &Owner{
ID: "qcs::cam::uin/100000760461:uin/100000760461",
DisplayName: "100000760461",
},
StorageClass: "STANDARD",
Initiated: "2017-06-15T08:39:18.000Z",
},
},
Prefix: "t",
CommonPrefixes: []string{"test/"},
}
if !reflect.DeepEqual(ref, want) {
t.Errorf("Bucket.ListMultipartUploads returned \n%+v, want \n%+v", ref, want)
}
}