-
Notifications
You must be signed in to change notification settings - Fork 92
/
service_test.go
70 lines (63 loc) · 1.42 KB
/
service_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
package cos
import (
"context"
"encoding/xml"
"fmt"
"net/http"
"reflect"
"testing"
)
func TestServiceService_Get(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `<ListAllMyBucketsResult>
<Owner>
<ID>xbaccxx</ID>
<DisplayName>100000760461</DisplayName>
</Owner>
<Buckets>
<Bucket>
<Name>huadong-1253846586</Name>
<Location>ap-shanghai</Location>
<CreationDate>2017-06-16T13:08:28Z</CreationDate>
</Bucket>
<Bucket>
<Name>huanan-1253846586</Name>
<Location>ap-guangzhou</Location>
<CreationDate>2017-06-10T09:00:07Z</CreationDate>
</Bucket>
</Buckets>
</ListAllMyBucketsResult>`)
})
opt := &ServiceGetOptions{
MaxKeys: 10,
}
ref, _, err := client.Service.Get(context.Background(), opt)
if err != nil {
t.Fatalf("Service.Get returned error: %v", err)
}
want := &ServiceGetResult{
XMLName: xml.Name{Local: "ListAllMyBucketsResult"},
Owner: &Owner{
ID: "xbaccxx",
DisplayName: "100000760461",
},
Buckets: []Bucket{
{
Name: "huadong-1253846586",
Region: "ap-shanghai",
CreationDate: "2017-06-16T13:08:28Z",
},
{
Name: "huanan-1253846586",
Region: "ap-guangzhou",
CreationDate: "2017-06-10T09:00:07Z",
},
},
}
if !reflect.DeepEqual(ref, want) {
t.Errorf("Service.Get returned %+v, want %+v", ref, want)
}
}