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, ` test-1253846586 1000 t / false test/ test_multipart.txt 14972623850a5de3f4f10605ab9f339c8bdf1b77e06f03fb981e7e76c86554b7bdb6072b36 100000760461/100000760461 100000760461/100000760461 STANDARD 2017-06-12T10:13:05.000Z test_multipar2t.txt 1497515958744e899fc341bfbb995ebd57b395f63930411d855aaac1b5cd7d834a15442831 qcs::cam::uin/100000760461:uin/100000760461 100000760461 qcs::cam::uin/100000760461:uin/100000760461 100000760461 STANDARD 2017-06-15T08:39:18.000Z `) }) 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) } }