Chris Lu
6 years ago
6 changed files with 121 additions and 54 deletions
-
13weed/s3api/filer_multipart.go
-
26weed/s3api/filer_multipart_test.go
-
1weed/s3api/s3api_bucket_handlers_test.go
-
46weed/s3api/s3api_objects_list_handlers.go
-
38weed/s3api/s3api_objects_list_handlers_test.go
-
51weed/s3api/s3api_xsd_generated.go
@ -0,0 +1,26 @@ |
|||
package s3api |
|||
|
|||
import ( |
|||
"github.com/aws/aws-sdk-go/aws" |
|||
"github.com/aws/aws-sdk-go/service/s3" |
|||
"testing" |
|||
) |
|||
|
|||
func TestInitiateMultipartUploadResult(t *testing.T) { |
|||
|
|||
expected := `<?xml version="1.0" encoding="UTF-8"?> |
|||
<InitiateMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Bucket>example-bucket</Bucket><Key>example-object</Key><UploadId>VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA</UploadId></InitiateMultipartUploadResult>` |
|||
response := &InitiateMultipartUploadResult{ |
|||
CreateMultipartUploadOutput: s3.CreateMultipartUploadOutput{ |
|||
Bucket: aws.String("example-bucket"), |
|||
Key: aws.String("example-object"), |
|||
UploadId: aws.String("VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA"), |
|||
}, |
|||
} |
|||
|
|||
encoded := string(encodeResponse(response)) |
|||
if encoded != expected { |
|||
t.Errorf("unexpected output: %s\nexpecting:%s", encoded, expected) |
|||
} |
|||
|
|||
} |
@ -0,0 +1,38 @@ |
|||
package s3api |
|||
|
|||
import ( |
|||
"testing" |
|||
"time" |
|||
) |
|||
|
|||
func TestListObjectsHandler(t *testing.T) { |
|||
|
|||
// https://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html
|
|||
|
|||
expected := `<?xml version="1.0" encoding="UTF-8"?> |
|||
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>test_container</Name><Prefix></Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>1.zip</Key><ETag>"4397da7a7649e8085de9916c240e8166"</ETag><Size>1234567</Size><Owner><ID>65a011niqo39cdf8ec533ec3d1ccaafsa932</ID></Owner><StorageClass>STANDARD</StorageClass><LastModified>2011-04-09T12:34:49</LastModified></Contents></ListBucketResult>` |
|||
|
|||
response := ListBucketResult{ |
|||
Name: "test_container", |
|||
Prefix: "", |
|||
Marker: "", |
|||
NextMarker: "", |
|||
MaxKeys: 1000, |
|||
IsTruncated: false, |
|||
Contents: []ListEntry{{ |
|||
Key: "1.zip", |
|||
LastModified: time.Date(2011, 4, 9, 12, 34, 49, 0, time.UTC), |
|||
ETag: "\"4397da7a7649e8085de9916c240e8166\"", |
|||
Size: 1234567, |
|||
Owner: CanonicalUser{ |
|||
ID: "65a011niqo39cdf8ec533ec3d1ccaafsa932", |
|||
}, |
|||
StorageClass: "STANDARD", |
|||
}}, |
|||
} |
|||
|
|||
encoded := string(encodeResponse(response)) |
|||
if encoded != expected { |
|||
t.Errorf("unexpected output: %s\nexpecting:%s", encoded, expected) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue